|
-
Jan 27th, 2006, 10:40 PM
#1
Thread Starter
New Member
[RESOLVED] Noob here and I need some simple help
OK im new to this sight and could use some help. I am Makeing a simple program that will work but if you donot put ant thing in the spacesit messes up. its pretty much a a program for easy use of the distance formula.
heres the code i have all i need to program in is some way if the box is left blank then it equals 0
Private Sub cmdAdd_Click()
X1 = txtX1.Text
Y1 = txtY1.Text
X2 = txtX2.Text
Y2 = txtY2.Text
B = (X1 - X2) ^ 2 + (Y1 - Y2) ^ 2
B = Sqr(B)
picAnswer.Print B
End Sub
if you guys can help I would really apprieate it
Last edited by Hack; Jan 30th, 2006 at 06:53 AM.
<-Sythe-<<
-
Jan 27th, 2006, 10:56 PM
#2
Re: Noob here and I need some simple help
Welcome to VBF!
You can try something like this...
VB Code:
If Len(txtX1.Text) = 0 Then
X1 = 0
Else
X1 = txtX1.Text
End If
-
Jan 27th, 2006, 11:07 PM
#3
Thread Starter
New Member
Re: Noob here and I need some simple help
that dident work my main problem is leaving the Text boxes blank and not having numbers in them If there was just a way to have a zero permantly put in front of the text box and only make it so you can type numbers. I need to get this because my teacher trys to crash the programs. Thanks
-
Jan 27th, 2006, 11:11 PM
#4
Re: Noob here and I need some simple help
You may try the validate event of your textboxes...
VB Code:
Private Sub txtX1_Validate(Cancel As Boolean)
If Len(txtX1) = 0 Then
txtX1.Text = "0"
Else
If Not IsNumeric(txtX1) Then
txtX1.Text = "0"
End If
End If
End Sub
-
Jan 27th, 2006, 11:18 PM
#5
Thread Starter
New Member
Re: Noob here and I need some simple help
cool cool that helped me, thanks man
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
|