CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2012
    Posts
    4

    Question HELP!! How to prevent Input of Alphabets in the code below >>>

    Thanks Guys Problem Solved For That Part

    ---------------------------------------------------------
    POST EDITED BY HanneSThEGreaT to reflect original question
    ---------------------------------------------------------
    Do
    StudentDetails(X).English = InputBox("Please Enter English Marks")
    If StudentDetails(X).English < 0 Or StudentDetails(X).English > 100 Then
    MessageBox.Show("Invalid input!""Please enter a value not More then 100 or Less then 0!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End If
    Loop While (StudentDetails(X).English < 0 Or StudentDetails(X).English > 100)

    -------------------------------------------------------------
    Last edited by HanneSThEGreaT; December 11th, 2012 at 03:59 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    Easy. Convert it to a list of numbers, and have them pick one. Kind of like a cell phone does
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    Assign the value of the InputBox to a string. Check the string to see if it IsNumeric.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    and positive, and not HEX #F4, and not a fraction, and ...

    Drop down is better, with ALL the choices
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    Quote Originally Posted by Rush1991 View Post
    Do
    StudentDetails(X).English = InputBox("Please Enter English Marks")
    If StudentDetails(X).English < 0 Or StudentDetails(X).English > 100 Then
    MessageBox.Show("Invalid input!""Please enter a value not More then 100 or Less then 0!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End If
    Loop While (StudentDetails(X).English < 0 Or StudentDetails(X).English > 100)
    Rsuh, please don't just slpa code together and post it here, without any sort of explanation - hence the confusion. I can suggest use AND instead of OR

    Quote Originally Posted by Mur16 View Post
    Assign the value of the InputBox to a string. Check the string to see if it IsNumeric.
    Yes

    Quote Originally Posted by dglienna View Post
    and positive, and not HEX #F4, and not a fraction, and ...

    Drop down is better, with ALL the choices
    David, what are you smoking? You cannot be serious.

  6. #6
    Join Date
    Dec 2012
    Posts
    4

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    [I]Sorry Guys. I Have Done Thanks..
    Last edited by Rush1991; December 11th, 2012 at 04:04 AM.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    Rush. Some more forum ethics here :

    First, use the Report post feature only to report spam or insulting posts. That is all that will get removed.

    Second, You have edited your first post in this thread, rendering this thread entirey completely and wholely useless.

    This is a forum, where questions are asked and questions are answered. That is the whole definition of the word forum. Now, people having the same problem as you will never ever find their answers because of your selfishness. I will Go back, and edit your first post to reflect the original question again.

    Please don't do it again, and please only use the report post feature to report spam

    Hannes

  8. #8
    Join Date
    Dec 2012
    Posts
    4

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    sorry im new here i did not know

  9. #9
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    No problem. Now you do know

  10. #10
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: HELP!! How to prevent Input of Alphabets in the code below >>>

    Hannes, &H100 is a Number. Why do you think cellphones don't have you type time or date fields out by hand?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured