i have here a code for my enlistment module..this code is for the available slot. for example i have set 10 as available slot and when i enlist a student 10 will become 9 and so on..my problem is when it reach zero because i can still enlist but the available slot becomes -1...how do i solve this?

   Public Sub auto()

    Dim x As Integer
    x = TextBox3.Text
    TextBox3.Text = Format(x - 1)

End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
auto()

        MessageBox.Show("Enlisted", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information)
        If TextBox3.Text = "0" Then
            MessageBox.Show("Slots are full", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

   end sub     

How about checking to see if it is less than zero?

if Integer.Parse(TextBox3.Text) < 0 then '...'

Hi jhedonghae,
Always try to debug your code by observing flow of control in the code. After reading your post I think following code you need

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim x As Integer
    x = TextBox3.Text
    If x <= 0 Then
        MessageBox.Show("Slots are full", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Else
        TextBox3.Text = Format(x - 1)
        MessageBox.Show("Enlisted", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End If
End Sub

tnx

commented: Do promise to debug yourself +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.