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.

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

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.

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?

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.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.