Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Number not 0-100 display messagebox

$
0
0
hi this assignment asks me to put a grade percentage(1-100) in textbox1 and a letter grade(A,B,C,D,F) would appear in the 2nd textbox, i nailed that part.
What i really need help is if i type lets say "a" or "hello" or "101" in the 1st textbox a msgbox should appear and tell you to type a number. i know how to display msgbox when i dont want numbers in txtbox1 like:

ex : If not isnumberic(textbox1.text) Then
messagebox.show("Words only please")

But in this case, i need to exclude words/letters, anything lower than 0, and anything higher than 100. its in the private sub textbox1_leave.

Thanks!


Option Strict On
Public Class FrmAssignGrades

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim gradepercent As Integer
        gradepercent = CInt(textbox1.Text)

        Dim lettergrade As String
        lettergrade = CStr(textbox2.Text)
        Select Case gradepercent
            Case 90 To 100
                lettergrade = "A"
            Case 80 To 89
                lettergrade = "B"
            Case 70 To 79
                lettergrade = "C"
            Case 60 To 69
                lettergrade = "D"
            Case 0 To 59
                lettergrade = "F"

        End Select
        textbox2.Text = CStr(lettergrade)





    End Sub


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>