Computing.Net > Forums > Programming > small & simple vb program..help pls

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

small & simple vb program..help pls

Reply to Message Icon

Name: danny
Date: February 10, 2003 at 16:31:50 Pacific
OS: Windows 2000 Professional
CPU/Ram: Pentium 4/2.2Ghz w/512pc2
Comment:

hey guys, got a small vb program to create and am receving a compile error. here is the code..tell me what i'm doing wrong. the program is basically 2 text boxes, 1 label box and a command button.
code:

Private Sub cmdStart_Click()
intNum1 = InputBox("Please enter a number.", "First Number")
intNum2 = InputBox("Please enter a second number.", "Second Number")
If intNum1 > intNum2 Then
l1.Caption = ">"
t1.Text = intNum1
t2.Text = intNum2
ElseIf intNum2 > intNum1 Then
l1.Caption = ">"
t1.Text = intNum2
t2.Text = intNum1
Else
l1.Caption = ">"
t1.Text = intNum2
t2.Text = intNum1
End If

End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: BelAnWel
Date: February 10, 2003 at 17:19:39 Pacific
Reply:

what the error? i tried it and it works, except for the part where u didnt declare the variables intnum1 and intnum2.


0

Response Number 2
Name: danny
Date: February 10, 2003 at 17:24:15 Pacific
Reply:

i did declare them jus forgot to put it here.
Dim intNum1 As Integer
Dim intNum2 As Integer


still dont work :(


0

Response Number 3
Name: BelAnWel
Date: February 10, 2003 at 17:58:12 Pacific
Reply:

what was the error message?


0

Response Number 4
Name: dizz
Date: February 10, 2003 at 18:19:37 Pacific
Reply:

---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Method or data member not found
---------------------------
OK Help
---------------------------


0

Response Number 5
Name: dizz
Date: February 10, 2003 at 19:33:27 Pacific
Reply:

someone please help?


0

Related Posts

See More



Response Number 6
Name: Fred Lyhne
Date: February 11, 2003 at 07:09:35 Pacific
Reply:

The inputbox function returns a STRING
ergo you must declare your variable as such
frx:

dim strNum1 as string

strNum1=InputBox("Please enter a number.", "First Number")


0

Response Number 7
Name: Val
Date: February 12, 2003 at 11:02:38 Pacific
Reply:

Try This
Private Sub Command1_Click()
Dim t1, t2, intNum1, intNum2 As String

intNum1 = InputBox("Please enter a number.", "First Number")
intNum2 = InputBox("Please enter a second number.", "Second Number")
If CInt(intNum1) > CInt(intNum2) Then
l1.Caption = ">"
Me.t1.Text = intNum1
Me.t2.Text = intNum2
ElseIf intNum2 > intNum1 Then
l1.Caption = ">"
Me.t1.Text = intNum2
Me.t2.Text = intNum1
Else
l1.Caption = ">"
t1.Text = intNum2
t2.Text = intNum1
End If

End Sub


0

Response Number 8
Name: Hector
Date: February 12, 2003 at 17:22:35 Pacific
Reply:

This works just fine.

Private Sub cmdStart_Click()
IntNum1 = InputBox("Please enter a number.", "First Number")
IntNum2 = InputBox("Please enter a second number.", "Second Number")
If IntNum1 > IntNum2 Then
Label1.Caption = " IntNum1 Then
Label1.Caption = "Lessor-->"
Text1.Text = IntNum2
Text2.Text = IntNum1
Else
Label1.Caption = ""
Text1.Text = IntNum2
Text2.Text = IntNum1
End If

End Sub


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: small & simple vb program..help pls

VB programming help needed www.computing.net/answers/programming/vb-programming-help-needed/7718.html

VB Programming help www.computing.net/answers/programming/vb-programming-help/9032.html

VB6 File rename help www.computing.net/answers/programming/vb6-file-rename-help/6388.html