Help with a VB Program

Discussion in 'Software' started by pclover, Oct 7, 2009.

  1. pclover

    pclover MajorGeek

    My code
    Code:
    Public Class Beep
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            System.Console.Beep(TextBox1.Text, TextBox2.Text)
        End Sub
    
        Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    
        End Sub
    
        Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Timer1.Enabled = True
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Timer1.Enabled = False
        End Sub
    
        Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Me.Hide()
            ShowInTaskbar = False
        End Sub
    
        Private Sub Beep_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    End Class
    
    Now the problem is I want to add it so textbox 1 is 37 to 32767 and if anything else besides these numbers are entered it will popup a message saying "Error: Enter a number between 37 and 32767 for Hz"

    Right now if I enter in a number like 36 it will cause an exception error.

    Also I would like to set for texbox2 the max is 900 and if you go over it it will say "Error: Enter a number below 901"

    Thanks for the help
     
  2. da.bell

    da.bell Private First Class

    have you tried to put a maxlength into your textbox? When it comes to minvalues's you could code it before submission and along with a requiredfieldvalidator check that if the length doesn't equal something greater than your min value, do not proceed.

    I don't know where you are getting the exception rule but you can also code a Try/Catch/Finally $.02

    Basing the validation on web forms programming and not windows.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds