1,105,592 Community Members

error trapping

Member Avatar
yeeitsneo
Light Poster
41 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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)
Member Avatar
Jx_Man
Senior Poster
3,543 posts since Nov 2007
Reputation Points: 987 [?]
Q&As Helped to Solve: 542 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

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

Member Avatar
yeeitsneo
Light Poster
41 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
BitBlt
Practically a Posting Shark
895 posts since Feb 2011
Reputation Points: 442 [?]
Q&As Helped to Solve: 163 [?]
Skill Endorsements: 16 [?]
Featured
 
0
 

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?

Member Avatar
yeeitsneo
Light Poster
41 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
yeeitsneo
Light Poster
41 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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)
Member Avatar
abelingaw
Posting Whiz in Training
247 posts since Jun 2008
Reputation Points: 69 [?]
Q&As Helped to Solve: 32 [?]
Skill Endorsements: 2 [?]
 
0
 

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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: