|
-
Mar 11th, 2011, 06:55 PM
#1
Thread Starter
Junior Member
-
Mar 11th, 2011, 08:01 PM
#2
Re: Help with Prevention of Dividing by Zero
Try using the "or" condition.
vb Code:
Private Sub Form_Load() 'To stop yourself from dividing by zero. If Val(Text1.Text) And Val(Text2.Text) = 0 or If Val(Text1.Text) And Val(Text2.Text) <> 0 Then cmdDivide.Enabled = False else cmdDivide.Enabled = True End If End Sub
I haven't tested the code but it should work.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Mar 11th, 2011, 08:04 PM
#3
Re: Help with Prevention of Dividing by Zero
Code:
Private Sub Form_Load()
'To stop yourself from dividing by zero.
If Val(Text1.Text) Then cmdDivide.Enabled = True Else cmdDivide.Enabled = False
End Sub
-
Mar 11th, 2011, 08:11 PM
#4
Re: Help with Prevention of Dividing by Zero
Code Doc, I think it should be Text2, not Text1. From 1st post, it appears Text2 will be the divisor
-
Mar 11th, 2011, 08:20 PM
#5
Re: Help with Prevention of Dividing by Zero
 Originally Posted by LaVolpe
Code Doc, I think it should be Text2, not Text1. From 1st post, it appears Text2 will be the divisor
+1, Fox. You only have to check for the denominator (or divisor). Looks like Text2.Text contains the divisor. OP should advise. If so,
Code:
Private Sub Form_Load()
'To stop yourself from dividing by zero.
If Val(Text2.Text) Then cmdDivide.Enabled = True Else cmdDivide.Enabled = False
End Sub
-
Mar 11th, 2011, 10:08 PM
#6
Thread Starter
Junior Member
Re: Help with Prevention of Dividing by Zero
Thank you Nightwalker83! It works now.
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
|