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.
Whats wrong with this VB code?
Name: Tidus Date: January 10, 2004 at 18:40:14 Pacific OS: Winxp CPU/Ram: ?
Comment:
Private Sub txt1_Change() If txt1.Text <> Y Or txt1.Text <> N Then MsgBox("Only Y and N please", vbOKOnly, "Only Y or N please", None, None) = vbOK End Sub
-
Whats wrong with the code? >< Sry im only in grade 10 Computer science class, still learning, so No flaming please i just want to know how i can make it ::Beep:: and stop people from entering anything other than "Y" or "N" in the textbox, thanks.
Name: Tidus Date: January 10, 2004 at 18:41:38 Pacific
Reply:
EDIT: O i forgot to enter this part in the code, it still doesnt work:
-----------------
Private Sub txt1_Change() If txt1.Text <> Y Or txt1.Text <> N Then MsgBox("Only Y and N please", vbOKOnly, "Only Y or N please", None, None) = vbOK End if 'Edited Part End Sub
----------------
0
Response Number 2
Name: egkenny Date: January 10, 2004 at 19:37:39 Pacific
Reply:
Private Sub txt1_Change() If txt1.Text <> "Y" And txt1.Text <> "N" Then Result = MsgBox("Only Y and N please", vbOKOnly, "Only Y or N please") End If End Sub
0
Response Number 3
Name: Tidus Date: January 10, 2004 at 20:04:16 Pacific
Reply:
Wait...
[quote]
If txt1.Text <> "Y" And txt1.Text <> "N" Then
[/quote]
And?? That would mess it up wouldnt it cuz im trying to get a yes or no answer. Cant enter both letters at the same time? Would OR work in the same code? -.-
0
Response Number 4
Name: egkenny Date: January 10, 2004 at 20:59:07 Pacific
Reply:
No, the statement I gave is correct An important law to use when you are working with computer logic is: De Morgan's laws not (P and Q) = (not P) or (not Q) not (P or Q) = (not P) and (not Q)
Here is the PROOF
We start with what we want to be true: (txt1.Text = "Y") or (txt1.Text = "N")
We want to invoke the Message box ONLY when that is NOT true:
not((txt1.Text = "Y") or (txt1.Text = "N"))
By using De Morgan's laws this is equal to: not(txt1.Text = "Y") and not(txt1.Text = "N") (txt1.Text <> "Y") and (txt1.Text <> "N")
0
Response Number 5
Name: Sord Date: January 11, 2004 at 16:08:46 Pacific
Summary: Hi all I have some problem with ASP script. If someone can help me to point out what I am doing wrong. Below you can see the code. It works as follow: When one click on "Add a customer" button with al...
Summary: Can anyone spot anything wrong with this code? It wont compile for some reason. Private Sub Form_Load() Open "InfoL.txt" For Input As #1 Input #1, txtLogin.Text Close #1 Open "InfoP.txt" For Input As ...
Summary: Can someone please tell me what is wrong with this VB code? It's supposed to calculate prime numbers. When I go through it maunually, it works, but it doesn't when i run it. It keeps comiong up with...