Registration Program


This is a demo program for registration. The inputs are name, sex, year of birth, email address and country. The inputs have been taken using the TextBox and ComboBox controls. You can learn about some important properties of the ComboBox control.

             
                                                   >> DOWNLOAD


Screenshot:
Properties and methods of Combo box


Code:
Private Sub cmdRegister_Click()
    If txtName = "" Then
        MsgBox "Please enter your name ", vbExclamation, "Error"
        txtName.SetFocus
        Exit Sub      'this statement will exit the sub-routine
    End If

    If cboDay.ListIndex = -1 Then
        MsgBox "Please select a day for your birthday", _

        vbExclamation, "Error"
        cboDay.SetFocus
        Exit Sub
    End If

    If cboMonth.ListIndex = -1 Then
        MsgBox "Please select a month for your birthday", _

        vbExclamation, "Error"
        cboMonth.SetFocus
        Exit Sub
    End If

    If cboYear.ListIndex = -1 Then
        MsgBox "Please select a year for your birthday", _

        vbExclamation, "Error"
        cboYear.SetFocus
        Exit Sub
    End If

    If cboGender.ListIndex = -1 Then
        MsgBox "Please select gender", vbExclamation, "Error"
        cboGender.SetFocus
        Exit Sub
    End If


    If txtEmail.Text = "" Then
        MsgBox "Please enter your email address", _

        vbExclamation, "Error"
        txtEmail.SetFocus
        Exit Sub
    End If

    If txtEmailAgain.Text = "" Then
        MsgBox "Please re-enter your email address", _

        vbExclamation, "Error"
        txtEmailAgain.SetFocus
        Exit Sub
    End If

    If txtEmail.Text <> txtEmailAgain.Text Then
        MsgBox "email address mismatch !!!", vbExclamation, "Error"
        txtEmail.SetFocus
        Exit Sub
    End If

    If cboCountry.ListIndex = -1 Then
        MsgBox "Please select your country", vbExclamation, "Error"
        cboCountry.SetFocus
        Exit Sub
    End If

    MsgBox "Name - " + txtName + Chr(13) + "Birthday - " + _

    cboDay.Text + " " + cboMonth.Text +
    cboYear.Text _

    + Chr(13) + "Gender - " + cboGender.Text + Chr(13) + _
    "Email address - " + txtEmail.Text +
    Chr(13) + _

    "Country -" + cboCountry.Text, vbInformation, _
    "Registration Successful !!!"

    End

End Sub
________________________________________________
Private Sub Form_Load()
    cboGender.AddItem "Male"
    cboGender.AddItem "Female"

    cboCountry.AddItem "England"
    cboCountry.AddItem "USA"
    cboCountry.AddItem "France"
    cboCountry.AddItem "India"
    cboCountry.AddItem "Germany"
    cboCountry.AddItem "China"
    cboCountry.AddItem "Japan"
    cboCountry.AddItem "Bangladesh"


    For d = 1 To 30
        cboDay.AddItem Str(d)
        d = Val(d)
    Next d

    cboMonth.AddItem "January"
    cboMonth.AddItem "February"
    cboMonth.AddItem "March"
    cboMonth.AddItem "April"
    cboMonth.AddItem "May"
    cboMonth.AddItem "June"
    cboMonth.AddItem "July"
    cboMonth.AddItem "August"
    cboMonth.AddItem "September"
    cboMonth.AddItem "October"
    cboMonth.AddItem "November"
    cboMonth.AddItem "December"

    For y = 1980 To 2012
        cboYear.AddItem Str(y)
        y = Val(y)
    Next y

    End Sub