954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

error trapping

hi. im currently making a program. and im having a bit of a problem with checking if inputs on my text boxes correspond to the one im requiring the user to input.

see. i have three text boxes.
i only allow users to input q,d and n into each textbox.
soo there should be error messages each time a wrong input is made.

ill attach the form here so you guys could help me out.
thankyou so much.

Attachments mealy1.zip (2.18KB)
yeeitsneo
Newbie Poster
22 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

So, What the error of your program?
I don't get what exactly you want to ask?

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 
So, What the error of your program? I don't get what exactly you want to ask?


uhmm. have you run the program?
uhmm. my problem goes this way

see. i have a text box. it must only accept letters q or d or n.
if any input besides this letter is made a msg box must appear that saysthat the input is incorrect.

if you try to run my program. im having difficulty in placing such conditions that check if the inputs on the text fields are correct.

i have already written those conditional statements that check my textboxes. my problem is i cant really place them in the right position so that all my "error" messages would go smoothly.

yeeitsneo
Newbie Poster
22 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

As a starter, you might consider separating your logic by testing the inputs first and waiting to do your calculations and shape-color-changing for later in the routine.

Simple test:

If Not (UCase(Text1.Text) Like "[QDN]") Then
    MsgBox "INVALID COIN!PLEASE INSERT COIN in Q,D and N ONLY!", vbCritical, "INSERT COIN"
    Exit Sub
End If


This will test for a valid value and hoist a message box if it is invalid then get out of the event routine. Simplifies your logic and you don't have to be continually testing.

If it's not too much trouble, could you explain what the Label4.Caption is supposed to be showing? I couldn't really figure out what you're trying to accomplish there. Also, what is the significance of the different Shape controls changing color?

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

As a starter, you might consider separating your logic by testing the inputs first and waiting to do your calculations and shape-color-changing for later in the routine.

Simple test:

If Not (UCase(Text1.Text) Like "[QDN]") Then
    MsgBox "INVALID COIN!PLEASE INSERT COIN in Q,D and N ONLY!", vbCritical, "INSERT COIN"
    Exit Sub
End If

This will test for a valid value and hoist a message box if it is invalid then get out of the event routine. Simplifies your logic and you don't have to be continually testing.

If it's not too much trouble, could you explain what the Label4.Caption is supposed to be showing? I couldn't really figure out what you're trying to accomplish there. Also, what is the significance of the different Shape controls changing color?

ill try to revise my code. but still if i cant do it could you help me out revising it? :)

uhm .actually this is a mealy machine. changing color of the shapes mean a change in state. or a transition from one state to another.

yeeitsneo
Newbie Poster
22 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

As a starter, you might consider separating your logic by testing the inputs first and waiting to do your calculations and shape-color-changing for later in the routine.

Simple test:

If Not (UCase(Text1.Text) Like "[QDN]") Then
    MsgBox "INVALID COIN!PLEASE INSERT COIN in Q,D and N ONLY!", vbCritical, "INSERT COIN"
    Exit Sub
End If

This will test for a valid value and hoist a message box if it is invalid then get out of the event routine. Simplifies your logic and you don't have to be continually testing.

If it's not too much trouble, could you explain what the Label4.Caption is supposed to be showing? I couldn't really figure out what you're trying to accomplish there. Also, what is the significance of the different Shape controls changing color?


here. i updated my zip. hope you could check it out.

Attachments mealy.zip (41.67KB)
yeeitsneo
Newbie Poster
22 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

A revision of BitBIt's code:

If Text1.Text <> "q" or "Q" Then
    MsgBox "INVALID COIN!PLEASE INSERT COIN in Q,D and N ONLY!", vbCritical, "INSERT COIN"
    Exit Sub
End If


It accepts the specified letters in UCase and LCase.
Or you could use ASCII code equivalent of each letters.

abelingaw
Posting Whiz in Training
205 posts since Jun 2008
Reputation Points: 66
Solved Threads: 26
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: