Results 1 to 11 of 11

Thread: Help please

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Help please

    Can someone help me with a quick project.. The program consists of making 2 text boxes, one labeled Age, and one labeled Name.

    The Name text box must return the name in all uppercase.
    If the Age text box isn't filled with a numerical value, you should receive a message saying "need a number" and return your cursor to the age box.
    2 command buttons "Process" and "Exit"

    Any help? I tried getting started, but I usually always work better when i have a beginning!
    Thanks!

  2. #2
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: Help please

    Put 2 textboxes on your form and 2 buttons.
    Then in the button click event for button 1 add this:
    Code:
    Messagebox.Show("Textbox 1 text in uppercase = " & TextBox1.Text.ToUpper() & Environment.NewLine & "Textbox 2 text is numeric = " & IsNumeric(TextBox2.Text))
    TextBox1 = Name textbox
    TextBox2 = Age textbox
    Button1 = Process button
    Button2 = Exit button
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Re: Help please

    okay i will give it a shot, thanks for your help!!

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Re: Help please

    hey i tried that, it says runtime error... I am using Visual basic 6.0.... the directions i had were along the lines using the code Name=(ucase)....
    do you know anything like this?

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Help please

    Welcome to VBForums.
    You could just set the TextBox' CharacterCasing property to Upper and everything written in the TextBox will always be all uppercase.

    As for the numeric TextBox, this has been discussed over and over on VBF.
    One way to do this is to not allow anything but numbers to be added in the first place, by doing something like this:

    VB.NET Code:
    1. Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    2.         If Not Char.IsNumber(Char.ConvertFromUtf32(e.KeyValue)) Then
    3.             e.SuppressKeyPress = True
    4.         End If
    5.     End Sub

    Another way is to simply use a NumericUpDown instead, which is designed for just these kinds of things.

    OR, keep the TextBox as is, and use Integer.TryParse:

    VB.NET Code:
    1. Dim value As Integer
    2.         If Integer.TryParse(TextBox1.Text, value) Then
    3.             'TextBox contained a valid integer. The variable value contains the integer.
    4.         Else
    5.             MessageBox.Show("Enter a valid integer")
    6.         End If

    Edit: VB6 eh? Well... you've posted in the wrong forum then.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: Help please

    Oh, you've posted this in the VB.Net forum.
    I'll get a solution for you in a minute...

    *See post #9
    Last edited by knxrb; Jan 8th, 2009 at 11:24 AM.
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help please

    Quote Originally Posted by JJones34
    I am using Visual basic 6.0....
    Moved to Visual Basic 6 And Earlier

    I'm not surprised you were getting an error. You were trying to run VB.NET code in a VB6 app.

    Your use of UCase is correct.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Re: Help please

    okay, wow thanks for the timely help. You guys sure know what you're talking about! Thanks again... knxrb- could you get me the exact code to type in? It seems as if once i get the exact code, and make my own adjustments i learn much easier. That is how i got through Cobol!!

  9. #9
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: Help please

    Here you go:
    Add 2 textboxes and 2 buttons like before and put this in the process button click event:
    Code:
     MsgBox ("text1.text uppercase = " & UCase(Text1.Text) & vbCrLf & "is text2.text numeric = " & IsNumeric(Text2.Text))
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

  10. #10

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Re: Help please

    Thank you! .. things are starting to work! However, is there somehow I can get it to change the text in the box to uppercase... right now it just pops up a message saying txtName.text = MIKE
    and is txtAge.text numeric = True

    Can i Email you a copy of the compiled program?

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Re: Help please

    I have a working .exe of the program, however my version is still a little different then the correct .exe program... do you have an email i can forward it too, its a really small program, doesn't take more than 10 seconds to download.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width