Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Programming Help in VB 6!! Need 1 tip or 2  (Read 15700 times)

0 Members and 1 Guest are viewing this topic.

drago87

    Topic Starter


    Rookie
    Re: Programming Help in VB!! Need 1 tip or 2
    « Reply #15 on: December 20, 2007, 08:54:23 AM »
    If i press the F1 i get "The MSDN collection does not exist. Please reinstall MSDN.
    But i cant find MSDN. So i can't install it.

    And Sendkeys "{enter}" can i write Sen keys "{u}" instead??
    and how do i do to take the information from the text boxes and use that key??

    By stop i mean to end the loop And Wait fore the F11 key to be pressed agen.

    Both the F10 and F11 i want to be accessed even if i hawnt got my own prog selected.
    « Last Edit: December 20, 2007, 10:08:46 AM by drago87 »

    drago87

      Topic Starter


      Rookie
      Re: Programming Help in VB!! Need 1 tip or 2
      « Reply #16 on: December 20, 2007, 10:52:59 AM »
      This is what it locks like

      Whid this i get a infernal loop when i press the F11 that i hawe to ctrl+alt+delet to get out off

      still dont now if i kan stop the loop whid the F10 button but it started whid the F11

      Code: (vb) [Select]
      Dim lop As Integer
      Dim PS1 As Integer
      Dim PS2 As Integer
      Dim AS1 As Integer
      Dim AS2 As Integer
      Dim AS1a As Integer
      Dim AS2a As Integer
      Dim repetetimes As Integer
      Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

      Private Sub AS1C_GotFocus()
      AS1C = ""
      End Sub

      Private Sub AS1T_GotFocus()
      AS1T = ""
      End Sub

      Private Sub AS2C_GotFocus()
      AS2C = ""
      End Sub

      Private Sub AS2T_GotFocus()
      AS2T = ""
      End Sub

      Private Sub Form_Load()

      Me.KeyPreview = True

      End Sub

      Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


      start:
      Debug.Print KeyCode, Shift
      Select Case KeyCode

      Case vbKeyF11

          lop = 1
          PS1 = CInt(PS1C.Text)
          PS2 = CInt(PS2C.Text)
          AS1 = CInt(AS1C.Text)
          AS2 = CInt(AS2C.Text)
          AS1a = CInt(AS1T.Text)
          AS2a = CInt(AS2T.Text)
          repetetimes = CInt(repet.Text)
         
         
          SendKeys "{u}" ' press the u key
          Sleep (500) ' wait for 0,5 sek

          If PS1C <> "Input" Then 'If the txt box PS1C is not empty then contineu
              SendKeys PS1 'press the button that is assigned to PS1C ex 1
              Sleep (500) ' wait for 0,5 sek
          End If
         
          If PS2C <> "Input" Then 'If the txt box PS2C is not empty then contineu
              SendKeys PS2 'press the button that is assigned to PS2C ex 2
              Sleep (500) ' wait 0,5 sek
          End If
      'Do Until Case vbKeyF10 'stop running the prog when press the F10 button

       
          Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
             
              If AS1C <> "Input" Then
                  SendKeys AS1 'press the button that is assigned to PS1C ex 3
                  Sleep (AS1a) 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
              End If
             
              If AS2C <> "Input" Then
                  SendKeys AS2 'press the button that is assigned to PS1C ex 4
                  Sleep (AS2a) 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
             
              End If
             
              lop = lop + 1
         
          Loop

      SendKeys "{p}" ' press the p key
      Sleep (10000) 'wait 10 sek
      lop = 1 ' resett the lop
      Case vbKeyF10
      'DoEvents() ' if i delet the ' before the DoEvents() i get a "syntax error"
      GoTo start
      'Loop
      End Select
      End Sub

      Private Sub PS1C_GotFocus()
      PS1C = ""
      End Sub

      Private Sub PS2C_GotFocus()
      PS2C = ""
      End Sub

      Private Sub repet_GotFocus()
      repet = ""
      End Sub

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Programming Help in VB!! Need 1 tip or 2
      « Reply #17 on: December 20, 2007, 01:20:15 PM »
      You had it right originally:

      1. SendKeys "u"

      I used a bad example, the curly braces are for keys on the keyboard that do not produce a character  (like enter, tab, backspace, etc).

      2. Do Until Case vbKeyF10 is illegal syntax; try Do Until vbKeyF10

      Case is part of the Select construct.

      3. Try using the DoEvents without the parenthesis. Not sure how helpful DoEvents will actually be; most times it's in a loop so the form can be updated. Hey! you never know.

      I probably should have asked this a lot sooner, but what version of VB are you using? If you're using an IDE, you can set checkpoints and then step into the code line by line to see how the program flows and what values the variables have.

       8)

      Maybe we should change the title of this post: "Re: Programming Help in VB!! Need 1 tip or 2"  ;D

      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      drago87

        Topic Starter


        Rookie
        Re: Programming Help in VB 6!! Need 1 tip or 2
        « Reply #18 on: December 20, 2007, 04:28:28 PM »
        The stop was only to inplement that i want the prog to stop running when the F10 was pressed
        i kant make the DoEvents to wurk
        i am using VB 6.0

        and i gotten to prog to youst lock fore a few sek then write u12 (in the box i had seleckted) and make the num lock go on and off once

        i still can't run the prog in eny other prog (like word)
         
        This is the whole code now

        Code: (vb) [Select]
        Dim lop As Integer
        Dim PS1 As Integer
        Dim PS2 As Integer
        Dim AS1 As Integer
        Dim AS2 As Integer
        Dim AS1a As Integer
        Dim AS2a As Integer
        Dim repetetimes As Integer
        Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

        Private Sub AS1C_GotFocus()
        AS1C = ""
        End Sub

        Private Sub AS1T_GotFocus()
        AS1T = ""
        End Sub

        Private Sub AS2C_GotFocus()
        AS2C = ""
        End Sub

        Private Sub AS2T_GotFocus()
        AS2T = ""
        End Sub

        Private Sub Form_Load()

        Me.KeyPreview = True

        End Sub

        Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

        'start:
        Debug.Print KeyCode, Shift
        Select Case KeyCode

        Case vbKeyF11

            lop = 1
            If PS1C > -1 And PS1C < 10 Then
                PS1 = CInt(PS1C.Text)
            End If
            If PS2C > -1 And PS2C < 10 Then
                PS2 = CInt(PS2C.Text)
            End If
            If AS1C > -1 And PS1C < 1 Then
                AS1 = CInt(AS1C.Text)
            End If
            If AS2C > -1 And AS2C < 10 Then
                AS2 = CInt(AS2C.Text)
            End If
            If AS1T > 0 Then
                AS1a = CInt(AS1T.Text)
            End If
            If AS2T > 0 Then
                AS2a = CInt(AS2T.Text)
            End If
            If repet > 0 Then
                repetetimes = CInt(repet.Text)
            Else
            MsgBox "You hawe to set more then that", vbInformation
            End If
           
           
            SendKeys "u" ' press the u key
            Sleep (500) ' wait for 0,5 sek

            If PS1C <> "Input" Then 'If the txt box PS1C is not empty then contineu
                SendKeys PS1 'press the button that is assigned to PS1C ex 1
                Sleep (500) ' wait for 0,5 sek
            End If
           
            If PS2C <> "Input" Then 'If the txt box PS2C is not empty then contineu
                SendKeys PS2 'press the button that is assigned to PS2C ex 2
                Sleep (500) ' wait 0,5 sek
            End If
        Do Until vbKeyF10 'stop running the prog when press the F10 button

         
            Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
               
                If AS1C <> "Input" Then
                    SendKeys AS1 'press the button that is assigned to PS1C ex 3
                    Sleep (AS1a) 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
                End If
               
                If AS2C <> "Input" Then
                    SendKeys AS2 'press the button that is assigned to PS1C ex 4
                    Sleep (AS2a) 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
               
                End If
               
                lop = lop + 1
           
            Loop

        SendKeys "p" ' press the p key
        Sleep (10000) 'wait 10 sek
        lop = 1 ' resett the lop
        'Case vbKeyF10
        DoEvents
        'GoTo start
        Loop
        End Select
        End Sub

        Private Sub PS1C_GotFocus()
        PS1C = ""
        End Sub

        Private Sub PS2C_GotFocus()
        PS2C = ""
        End Sub

        Private Sub repet_GotFocus()
        repet = ""
        End Sub

        Im i missing somthing??

        If i change the 3 first wait commands it locks fore a longer period of time then write ute the u12 is there a sulution to make it right after line
        Code: (vb) [Select]
        SendKeys "u" it uses it not wait untill it hawe done all?

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: Programming Help in VB 6!! Need 1 tip or 2
        « Reply #19 on: December 20, 2007, 06:03:46 PM »
        You have a set of nested do loops but the outer loop is incomplete unless the Case vbKeyF10 line is commented out. I suspect you'll eventually need that case statement.

        I may be missing something, but shouldn't PS1C and PS2C be initialized with values before you check to see if they are > -1 and < 10 ???

        The SendKeys "u" is correct syntax but the keystroke is at the cursor position. Where is the cursor? (I don't know either)

        Quote
        i still can't run the prog in eny other prog (like word)
        I'm not sure where you're going with this but to run this within the Word application you'd need to run it as a macro.

        VB is an event driven language which makes it perfect for interactive applications. Your program seems to be acting as both a program and a user in that it's creating the events and then running code in response. I know I'm a little slow on the uptake, but I still have no idea what you're trying to accomplish.

         8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        drago87

          Topic Starter


          Rookie
          Re: Programming Help in VB 6!! Need 1 tip or 2
          « Reply #20 on: December 21, 2007, 01:21:04 AM »
          word was just a exp i want to run it in 9Dragons a MMORPG

          tis is what it locks like before i press the F11

                                        Start F11
                                        Stop F10

                                     Skill Slot     Time (mS)

          Passive Skill 1         / 1 /
          Passive Skill 2         / 2 /

          Active Skill 1           / 3 /            / 2000 /
          Active Skill 2           / 4 /            / 3000 /


          Times to repeat       / 5/

          and if the cursor is located at the Times to repetwhen i press F11 it locks like this


          Times to repeat      /5u12/

          if i hawe it at the Active Skill 1 it looks like this

          Active skill 1          /1u12/

          so the check
              If PS1C > -1 And PS1C < 10 Then
                  PS1 = CInt(PS1C.Text)
              End If
          seems to work

          Well i'm going on wecation now so i cant complet it before new year.

          but i'l bump this later if i need more help

          So werry christmas and a happy new year.

          drago87

            Topic Starter


            Rookie
            Re: Programming Help in VB 6!! Need 1 tip or 2
            « Reply #21 on: January 06, 2008, 11:34:24 AM »
            Well i'm back and hawe the same problem.

            What is does so far.

            When i press the F11 button it locks fore about 1-3 sek and then it writes u and what i hawe wrutten in the first 2 text boxes then nothing more.

            What i want it to do.

            I want to be able to start it in eny program.
            It wont lock when i press F11.(whrites the u and the first 2 boxes whidout locking)
            It start writing the 3 and 4 text boxes(like this 3 wait 4 wait 3 wait 4 wait 3 wait 4 wait)
            The 3 and 4 from the last example can be change to enyting betwene 0 and 9 and the wait can be changed seperatly in the 2 boxes on the right
            The last box is for how meny times box 3 and 4 shell run before the prog press p
            The F10 button whill stop the loop
            All this whidout locking the computer betwene the writings.

            drago87

              Topic Starter


              Rookie
              Re: Programming Help in VB 6!! Need 1 tip or 2
              « Reply #22 on: January 07, 2008, 02:30:47 AM »
              Well i made som changes.

              Now it writes the 3 and 4 txt box and the p also but it still locks but i can move the mouse betveen the loops  and i still can't start it whidout having it marked.

              i think it can be the SendKeys command or the wait command


              Code: (vb) [Select]
              Dim lop As Integer
              Dim PS1 As Integer
              Dim PS2 As Integer
              Dim AS1 As Integer
              Dim AS2 As Integer
              Dim AS1a As Integer
              Dim AS2a As Integer
              Dim repetetimes As Integer
              Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
              Dim bCancel As Boolean

              Private Sub AS1C_GotFocus()
              AS1C = ""
              End Sub

              Private Sub AS1T_GotFocus()
              AS1T = ""
              End Sub

              Private Sub AS2C_GotFocus()
              AS2C = ""
              End Sub

              Private Sub AS2T_GotFocus()
              AS2T = ""
              End Sub

              Private Sub Form_Load()

              Me.KeyPreview = True

              End Sub

              Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


              Debug.Print KeyCode, Shift
              Select Case KeyCode

              Case vbKeyF11
                  bCancel = False

                  PS1C.Enabled = False 'So that you dont change it when it runns
                 
                  lop = 1
                  If PS1C <> "Input" And PS1C <> "" Then
                      PS1 = CInt(PS1C.Text)
                  End If
                  If PS2C <> "Input" And PS2C <> "" Then
                      PS2 = CInt(PS2C.Text)
                  End If
                  If AS1C <> "Input" And PS1C <> "" Then
                      AS1 = CInt(AS1C.Text)
                  End If
                  If AS2C <> "Input" And AS2C <> "" Then
                      AS2 = CInt(AS2C.Text)
                  End If
                  If AS1T <> "Input" And AS1T <> "" Then
                      AS1a = CInt(AS1T.Text)
                  End If
                  If AS2T <> "Input" And AS2T <> "" Then
                      AS2a = CInt(AS2T.Text)
                  End If
                  If repet <> "Input" And repet <> "" And repet > 0 Then
                      repetetimes = CInt(repet.Text)
                  Else
                  MsgBox "You hawe to set more then that", vbInformation
                  End If
                 
                 
                  SendKeys "u" ' press the u key
                  Sleep (500) ' wait for 0,5 sek

                  If PS1C <> "Input" And PS1C <> "" Then 'If the txt box PS1C is not empty then contineu
                      SendKeys PS1 'press the button that is assigned to PS1C ex 1
                      Sleep (500) ' wait for 0,5 sek
                  End If
                 
                  If PS2C <> "Input" And PS2C <> "" Then 'If the txt box PS2C is not empty then contineu
                      SendKeys PS2 'press the button that is assigned to PS2C ex 2
                      Sleep (500) ' wait 0,5 sek
                  End If
                  DoEvents
              Do While Not bCancel 'stop running the prog when press the F10 button

               
                  Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
                     
                      If AS1C <> "Input" Then
                          SendKeys AS1 'press the button that is assigned to PS1C ex 3
                          Sleep (AS1a) 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
                      End If
                     
                      If AS2C <> "Input" Then
                          SendKeys AS2 'press the button that is assigned to PS1C ex 4
                          Sleep (AS2a) 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
                     
                      End If
                     
                      lop = lop + 1
                      DoEvents
                  Loop

              SendKeys "p" ' press the p key
              Sleep (10000) 'wait 10 sek
              lop = 0 ' resett the lop
              'Case vbKeyF10
              DoEvents
              'GoTo start
              Loop

              Case vbKeyF10
                  bCancel = True
                  PS1C.Enabled = True
                 
              End Select

              End Sub

              Private Sub PS1C_GotFocus()
              PS1C = ""
              End Sub

              Private Sub PS2C_GotFocus()
              PS2C = ""
              End Sub

              Private Sub repet_GotFocus()
              repet = ""
              End Sub


              drago87

                Topic Starter


                Rookie
                Re: Programming Help in VB 6!! Need 1 tip or 2
                « Reply #23 on: January 15, 2008, 05:13:31 AM »
                -:Bump:-

                Still need help

                drago87

                  Topic Starter


                  Rookie
                  Re: Programming Help in VB 6!! Need 1 tip or 2
                  « Reply #24 on: January 22, 2008, 07:00:54 AM »
                  -:Bump:-