Results 1 to 7 of 7

Thread: this code i made not working anyone know why??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post


    Declare Function SetCursorPosition& Lib "user32" _
    (ByVal x As Long, ByVal y As Long)


    Sub setpos(txt1 As TextBox, txt2 As TextBox)
    If txt2.Text = "200" Then
    txt1.Text = txt1.Text + 1
    txt2.Text = "0"
    Else
    If txt1.Text = "200" Then
    txt1.Text = "0"
    Else
    t& = SetCursorPos(txt1.Text, txt2.Text)
    End If
    End If
    End Sub

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    I don't know what purpose this Routine serves, but there are a few mistakes..

    First of all, your declaration is wrong plus it's a function, yet you haven't defined a return type, then you're mixing your Data Types without converting them, anyhow, here's the code in working order:
    Code:
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    
    Sub setpos(txt1 As TextBox, txt2 As TextBox)
        If txt2.Text = "200" Then
            txt1.Text = Val(txt1.Text) + 1
            txt2.Text = "0"
        Else
            If txt1.Text = "200" Then
                txt1.Text = "0"
            Else
                Call SetCursorPos(Val(txt1.Text), Val(txt2.Text))
            End If
        End If
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    i stell keep getting a sub or funcition not defind

  4. #4
    New Member
    Join Date
    Nov 1999
    Location
    New Delhi
    Posts
    6

    Post


    XxEvilxX

    Can you write which sub or fuction is said as undefined by the Visual Basic Compiler?
    Then we can think about the real problem if it is related to the system DLL's.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    Is on the SetCursorPostion

  6. #6
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    The API call is NOT:
    Code:
    Declare Function SetCursorPosition& Lib "user32" (ByVal x As Long, ByVal y As Long)

    It is:

    Code:
    Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Notice that SetCursorPosition is wrong... it is SetCursorPos.

    You may however do the following:

    Code:
    Declare Function SetCursorPosition Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long
    and use SetCursorPosition.

    ------------------
    Tom Young, 14 Year Old
    [email protected]
    ICQ: 15743470
    AIM: TomY10
    PERL, JavaScript and VB Programmer

  7. #7
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    Aaron:

    Even though the API SetCursorPosition doesn't exist...

    Declare Function SetCursorPosition&
    Here Evil did define a return data type. The & ampersand is a shortcut to As Long.

    ------------------
    Yonatan
    Teenage Programmer
    E-Mail: [email protected]
    ICQ: 19552879



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width