Beginning Visual Basic Programming

Hi. . . Sure hope that as an IT student, it's okay for me to be here and ask "stupid" questions. I had a basic assignment to write a simple program: "Hello, World" only I wanted to rewrite the basic program and send it to my son (an IT specialist) as a kind of funny joke (as well as to impress him!). The following is my basic code (without all the fancy buttons and pictures): Option Explicit Private Sub cmdCLEAR_Click() lblHello.Caption = "" txtInputName.Text = "" cmdCLICKME.Enabled = False cmdCLEAR.Enabled = False txtInputName.SetFocus End Sub Private Sub cmdCLICKME_Click() lblHello.Caption = "Hi " & txtInputName & "" End Sub Private Sub cmdQUIT_Click() End End Sub Private Sub Form_Load() lblHello.Caption = "" End Sub Private Sub txtInputName_Change() cmdCLICKME.Enabled = True cmdCLEAR.Enabled = True End Sub Private Sub txtInputName_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If txtInputName <> "" Then cmdCLICKME.SetFocus cmdCLICKME_Click End If End If End Sub What I'm trying to figure out how to do (and so far unsuccessfully) is to write a (sub-routine?) that would reject anything my son types into the txtInputName box except for his "nickname" Jonnie. Now if he just types in "Jonathan" or "Jon" I'd like the program to respond with: Nope. Not it. What's your momma call you? Silly, I know. But this basic programming class I'm in has really fired up my curiosity and enthusiasm for really learning programming at heart and creative ways of solving problems. If anyone out cares to help me out, I'd really appreciate it. Thanks! Johannah Winchurch

Answer Wiki

Thanks. We'll let you know when a new response is added.

you need to check for the asc 13 or the OK button is pressed then get the contents of the textbox and then do the compare (best to convert the string in the textbox to either all uppercase (toupper() equivalent) or lowercase (unless you want it to be case dependant) .. you can then compare the strings (either a built in function) or by walking through the array and comparing character by character and if it matches then carry on othewise display the error message or a tooltip with the hint ..

in console mode c this is to me a trivial program but in any visual program i’m also a newbie

Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: