|
-
Apr 22nd, 2006, 08:29 AM
#1
Thread Starter
New Member
command button if statements
ok, i've got this so far:
VB Code:
Private Sub Command1_Click()
Command2.Enabled = True
List1.AddItem Label1.Caption
Dim number As Integer
number = lable1
If number <= 3 Then
MsgBox "You Must Enter 3 Or More Numbers To Make A Call"
End If
End Sub
basically, a msgbox is meant to pop up when you click the button and less than 3 numbers are in the label. as it stands, the message box appears no matter how many numbers are in the label when you click the button!
can you spot anything i've missed/done wrong?
(sorry for the continuous threads with this particular project, i'm just majorly stuck, i'll try to keep using this same thread for any questions to do with this particular project, so keep checking on it please!!!)
x.
-
Apr 22nd, 2006, 08:34 AM
#2
Re: command button if statements
typo on this line:
Add 'Option Explicit' to the top of all your forms / modules to catch things like this.
-
Apr 22nd, 2006, 09:01 AM
#3
Thread Starter
New Member
Re: command button if statements
i corrected the typo but it still displays the message box even if i enter more than 3 numbers!
now my code for adding text from the lable to a list doesn't work either:
VB Code:
List1.AddItem Lable1.Caption
grrr! .
x.
-
Apr 22nd, 2006, 09:12 AM
#4
Re: command button if statements
you need to test the length of the string
VB Code:
Private Sub Command1_Click()
Command2.Enabled = True
If Len(Label1.Caption) < 3 Then
MsgBox "You Must Enter 3 Or More Numbers To Make A Call"
Else
List1.AddItem Label1.Caption
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|