Please Help Me with my Script.

Author Message
iflymyhelishigh

  • Total Posts : 6
  • Scores: 0
  • Reward points : 0
  • Joined: 12/1/2008
  • Status: offline
Please Help Me with my Script. Monday, December 01, 2008 9:15 AM (permalink)
0
Original message moved by ebgreen
Reason : Moved to proper forum
Hello, I am learning VB 2008. I want to create a script that adds 5 numbers together, then submits it to a file on a website. I can obviously get the visual stuff done, but the scripting is hard. I want to have 5 text boxes as hour logger boxes which get added up and submitted to a file on my website. You enter the number into the box then submit it.

I also want to later get a log in system so that a worker can log into his own account to submit his own hours. This is all for my friends and for experimental purposes.
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: Please Help Me with my Script. Monday, December 01, 2008 9:19 AM (permalink)
    0
    You say Vb 2008. Do you mean VB.Net?
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      iflymyhelishigh

      • Total Posts : 6
      • Scores: 0
      • Reward points : 0
      • Joined: 12/1/2008
      • Status: offline
      RE: Please Help Me with my Script. Monday, December 01, 2008 9:20 AM (permalink)
      0
      I am not sure, the program itself is called Visual Basic 2008 Express which I heard is VB.NET.
       
      #3
        ebgreen

        • Total Posts : 8227
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        RE: Please Help Me with my Script. Monday, December 01, 2008 9:30 AM (permalink)
        0
        Yes, that would be .Net. This is a VBScript forum not a VB.Net forum. The two are not really all that related except for some vaguely similar syntax.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          iflymyhelishigh

          • Total Posts : 6
          • Scores: 0
          • Reward points : 0
          • Joined: 12/1/2008
          • Status: offline
          RE: Please Help Me with my Script. Monday, December 01, 2008 9:37 AM (permalink)
          0
          Oh, Sorry about that.
           
          #5
            ebgreen

            • Total Posts : 8227
            • Scores: 98
            • Reward points : 0
            • Joined: 7/12/2005
            • Status: offline
            RE: Please Help Me with my Script. Monday, December 01, 2008 9:51 AM (permalink)
            0
            Not a problem. You may get an answer here anyway. I don't do VB.Net, so I doubt that you will get from me. 
            "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
            Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
            http://www.visualbasicscript.com/m_47117/tm.htm
             
            #6
              iflymyhelishigh

              • Total Posts : 6
              • Scores: 0
              • Reward points : 0
              • Joined: 12/1/2008
              • Status: offline
              RE: Please Help Me with my Script. Monday, December 01, 2008 9:54 AM (permalink)
              0
              Well, would VB 6 be Visual Script? I have that software too, from a friend who used to do this stuff :)
               
              #7
                ebgreen

                • Total Posts : 8227
                • Scores: 98
                • Reward points : 0
                • Joined: 7/12/2005
                • Status: offline
                RE: Please Help Me with my Script. Monday, December 01, 2008 10:26 AM (permalink)
                0
                VB6 would not be VBScript. VB6 is Visual Basic. If you are learning then I would personally suggest VB.Net rather than VB6. It is a more modern language.
                "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
                Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
                http://www.visualbasicscript.com/m_47117/tm.htm
                 
                #8
                  TNO

                  • Total Posts : 2094
                  • Scores: 36
                  • Reward points : 0
                  • Joined: 12/18/2004
                  • Location: Earth
                  • Status: offline
                  RE: Please Help Me with my Script. Monday, December 01, 2008 10:37 AM (permalink)
                  0
                  VB6 = Visual Basic Before .NET was invented.
                  VB7 = VB.NET also known as Visual Basic 2002
                  VB8 = VB.NET also known as Visual Basic 2005
                  VB9 = VB.NET also known as Visual Basic 2008
                  VBX =  VB10, VB.NET. This is the Visual Basic released with Silverlight 2.0 and the .NET futures Release

                  VBS = VBScript, which is visual basic for primarily client side administration and HTML Application Development
                  VBA = Visual Basic For Applications. Which is the Visual Basic Language that comes built into Microsoft Office

                  To iterate is human, to recurse divine. -- L. Peter Deutsch
                   
                  #9
                    ginolard

                    • Total Posts : 1347
                    • Scores: 23
                    • Reward points : 0
                    • Joined: 8/11/2005
                    • Status: offline
                    RE: Please Help Me with my Script. Monday, December 01, 2008 8:38 PM (permalink)
                    0
                    Ok, firstly, don't use Text boxes.  Why?  Because whatever is entered into a textbox is treated as a string.  Vbscript is a bit more forgiving about data types but VB.NET (quite rightly) gets all pissy when you try and add two numbers together that are, in fact, strings.

                    Instead, use the NumericUpDown control

                    So let's assume you now have 5 NumericUpDown controls on your form.  To get the total of those you just add them all up as an integer

                     Dim MyTotal as Integer = Me.NumericUpDown1.Value _
                                                            + Me.NumericUpDown2.Value _
                                                            + Me.NumericUpDown3.Value _
                                                            + Me.NumericUpDown4.Value _
                                                            + Me.NumericUpDown5.Value
                     


                    You could, of course, be even cleverer about it and loop through all the controls in the form, check if they are NumericUpDown controls and then total the values

                     dim i as integer
                     For Each c as Control in me.Controls
                      If TypeOf C Is NumericUpDown Then
                      Dim nud As NumericUpDown = DirectCast(C, NumericUpDown )
                        i += nud.value
                      End If
                     Next
                     Msgbox i
                     


                    Now then, to uploada file to a webpage you are going to need to use the WebClient control.  The syntax is pretty easy so I'll just you an example

                     Dim wc as System.Net.WebClient
                     wc.UploadFile ("http:\\www.mywebsite.com","c:\temp\test.txt")
                     
                    <message edited by ginolard on Monday, December 01, 2008 8:40 PM>
                    Author of ManagePC - http://managepc.net

                     
                    #10
                      iflymyhelishigh

                      • Total Posts : 6
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 12/1/2008
                      • Status: offline
                      RE: Please Help Me with my Script. Thursday, December 04, 2008 11:24 AM (permalink)
                      0
                      Dim wc As System.Net.WebClient wc.UploadFile("http:\\www.mywebsite.com", "c:\temp\test.txt")"


                      My statement replies with a "End of Statement Expected error, any help?

                      Also, my complete code is

                      Public Class Form1
                       
                          Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                              Dim MyTotal As Integer = Me.NumericUpDown1.Value _
                                                            + Me.NumericUpDown2.Value _
                                                            + Me.NumericUpDown3.Value _
                                                            + Me.NumericUpDown4.Value _
                                                            + Me.NumericUpDown5.Value
                          End Sub
                       
                          
                       
                          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
                              Dim wc As System.Net.WebClient wc.UploadFile("http:\\www.mywebsite.com", "c:\temp\test.txt")
                          End Sub
                       End Class
                       
                      <message edited by iflymyhelishigh on Thursday, December 04, 2008 11:25 AM>
                       
                      #11
                        ebgreen

                        • Total Posts : 8227
                        • Scores: 98
                        • Reward points : 0
                        • Joined: 7/12/2005
                        • Status: offline
                        RE: Please Help Me with my Script. Thursday, December 04, 2008 2:05 PM (permalink)
                        0
                        Pretty sure that you need to escape the \s here:

                        Dim wc As System.Net.WebClient wc.UploadFile("http:\\www.mywebsite.com", "c:\temp\test.txt")

                        So it would become:

                        Dim wc As System.Net.WebClient wc.UploadFile("http:\\\\www.mywebsite.com", "c:\\temp\\test.txt")
                        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
                        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
                        http://www.visualbasicscript.com/m_47117/tm.htm
                         
                        #12

                          Online Bookmarks Sharing: Share/Bookmark

                          Jump to:

                          Current active users

                          There are 0 members and 1 guests.

                          Icon Legend and Permission

                          • New Messages
                          • No New Messages
                          • Hot Topic w/ New Messages
                          • Hot Topic w/o New Messages
                          • Locked w/ New Messages
                          • Locked w/o New Messages
                          • Read Message
                          • Post New Thread
                          • Reply to message
                          • Post New Poll
                          • Submit Vote
                          • Post reward post
                          • Delete my own posts
                          • Delete my own threads
                          • Rate post

                          2000-2012 ASPPlayground.NET Forum Version 3.9