PDA

Click to See Complete Forum and Search --> : this code i made not working anyone know why??


XxEvilxX
Nov 4th, 1999, 08:48 AM
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

Aaron Young
Nov 4th, 1999, 09:26 AM
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:

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
aarony@redwingsoftware.com
adyoung@win.bright.net

XxEvilxX
Nov 4th, 1999, 11:56 AM
i stell keep getting a sub or funcition not defind

Pratyush
Nov 4th, 1999, 12:31 PM
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.

XxEvilxX
Nov 5th, 1999, 08:32 PM
Is on the SetCursorPostion

Compwiz
Nov 5th, 1999, 10:39 PM
The API call is NOT:
Declare Function SetCursorPosition& Lib "user32" (ByVal x As Long, ByVal y As Long)


It is:

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:

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
tom@e-bizinternet.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer

Yonatan
Nov 6th, 1999, 12:15 AM
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: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)