Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Sub cmb10_Click()
- If MultiPage1.Value < MultiPage1.Pages.Count - 1 Then
- MultiPage1.Value = MultiPage1.Value + 1
- End If
- End Sub
- Private Sub cmb11_Click()
- If MultiPage1.Value > 0 Then
- MultiPage1.Value = MultiPage1.Value - 1
- End If
- End Sub
- Private Sub cmb12_Click()
- Me.Hide
- End Sub
- Private Sub cmb4_Click()
- If MultiPage1.Value < MultiPage1.Pages.Count - 1 Then
- MultiPage1.Value = MultiPage1.Value + 1
- End If
- End Sub
- Private Sub cmb5_Click()
- If MultiPage1.Value > 0 Then
- MultiPage1.Value = MultiPage1.Value - 1
- End If
- End Sub
- Private Sub cmb6_Click()
- Me.Hide
- End Sub
- Private Sub cmb7_Click()
- If MultiPage1.Value < MultiPage1.Pages.Count - 1 Then
- MultiPage1.Value = MultiPage1.Value + 1
- End If
- End Sub
- Private Sub cmb8_Click()
- If MultiPage1.Value > 0 Then
- MultiPage1.Value = MultiPage1.Value - 1
- End If
- End Sub
- Private Sub cmb9_Click()
- Me.Hide
- End Sub
- Private Sub cmbPlan_Change()
- With cmbPlan
- .AddItem "Essential"
- .AddItem "Ward"
- .AddItem "Semi-Private"
- .AddItem "Private"
- End With
- Dim Ans As String
- Ans = cmbPlan.Value
- End Sub
- Private Sub CommandButton1_Click()
- Me.Hide
- End Sub
- Private Sub Add_SatusItems()
- With ListBox_SmokingStatus
- .AddItem "Non-Smoker"
- .AddItem "Occasional"
- .AddItem "Regular"
- End With
- With ListBox_DrinkingStatus
- .AddItem "Non-Drinker"
- .AddItem "Occasional"
- .AddItem "Regular"
- End With
- With ListBox_LifestyleStatus
- .AddItem "Non-Active"
- .AddItem "Occasional"
- .AddItem "Regular"
- End With
- End Sub
- Private Sub cmb13_Click()
- On Error GoTo ErrorHandler
- Dim Firstname As String ' Updated variable name
- Dim address As String
- Dim DOB As Date
- Dim Planstart As Date
- Dim Age As Integer
- Dim Number As String
- Dim emnum As String
- Dim Occupation As String
- Dim HKID As String
- Dim Gender As String
- Dim Smoke As Boolean
- Dim Alcohol As Boolean
- Dim ChosenPlan As Date
- Dim Health As String
- Dim Lifestyle As String
- Dim paymentFreq As Integer
- Dim Premium As String
- Dim Dec As Boolean
- Dim Con As Boolean
- Call txtFirstname_Change
- Call txtDOB_Change
- Call txtAddress_Change
- Call txtContactNo_Change
- Call txtEmergencyNo_Change
- Call txtHKID_Change
- Call txtOccupation_Change
- Call cmbPlan_Change
- ' Rest of the code remains the same
- If Me.optbMale.Value = True Then
- Call optbMale_Click
- ElseIf Me.optbFemale.Value = True Then
- Call optbFemale_Click
- End If
- If Me.optbAllergiesYes.Value = True Then
- Call optbAllergiesYes_Click
- ElseIf Me.optbAllergiesNo.Value = True Then
- Call optaAllergiesNo_Click
- End If
- If optbMedConYes.Value = True Then
- Call optbMedConYes_Click
- ElseIf Me.optbMedConNo.Value = True Then
- Call optbMedConYes_Click
- End If
- If optbHealthConHyper.Value = True Then
- Call optbHealthConHyper_Click
- ElseIf optbHealthConDiabates.Value = True Then
- Call optbHealthConDiabates_Click
- ElseIf optbHealthConAsthma.Value = True Then
- Call optbHealthConAsthma_Click
- Else
- Call optbHealthConCancer_Click
- If optbAnyYes.Value = True Then
- Call optbAnyYes_Click
- Else
- optbAnyNo_Click
- Call ListBox_SmokingStatus_Click
- Call ListBox_DrinkingStatus_Click
- Call ListBox_LifestyleStatus_Click
- Call Premium_Click
- Call spinbYear_Change
- Call txtYear_Change
- Call btnDecrease_Click
- Call txtPayFreq_Change
- Call spinbPay_Change
- Call txtPlanDate_Change
- Call optbDeclaration_Click
- Call optbConsent_Click
- Alcohol = (Me.chkAlcohol.Value = True)
- Dec = (Me.chkDec.Value = True)
- Con = (Me.chkCon.Value = True)
- Dim Record As Worksheet
- Set Record = ThisWorkbook.Sheets("Enrollment")
- Dim nextRow As Long
- nextRow = Record.Range("A" & Record.Rows.Count).End(xlUp).Row + 1
- Record.Range("A" & nextRow).Value = Fname
- Record.Range("B" & nextRow).Value = Age
- Record.Range("C" & nextRow).Value = Gender
- Record.Range("D" & nextRow).Value = Occupation
- Record.Range("E" & nextRow).Value = HKID
- Record.Range("F" & nextRow).Value = Number
- Record.Range("G" & nextRow).Value = Smoke
- Record.Range("H" & nextRow).Value = Alcohol
- Record.Range("I" & nextRow).Value = Health
- Record.Range("J" & nextRow).Value = Lifestyle
- Record.Range("K" & nextRow).Value = ChosenPlan
- Record.Range("L" & nextRow).Value = Premium
- Record.Range("M" & nextRow).Value = paymentFreq
- MsgBox "Enrollment details saved successfully.", vbInformation
- Exit Sub
- ErrorHandler:
- MsgBox "An error occurred while saving the enrollment details.", vbCritical
- End Sub
- Private Sub ListBox_DrinkingStatus_Click()
- Dim selectedChoice As String ' Variable to store the user's choice
- With ListBox_DrinkingStatus
- .AddItem "Non-Drinker"
- .AddItem "Occasional"
- .AddItem "Regular"
- End With
- If ListBox_DrinkingStatus.ListIndex <> -1 Then ' Check if an item is selected
- selectedChoice = ListBox_DrinkingStatus.Value ' Store the selected choice
- Else
- MsgBox "Please select a drinking status." ' Display an error message if no item is selected
- End If
- ' Now you can use the selectedChoice variable for further processing or storing the value.
- ' Example: You can assign it to a different variable or use it in your code as needed.
- ' For example, if you have another variable called drinkChoice, you can assign the selectedChoice value to it:
- ' drinkChoice = selectedChoice
- End Sub
- Private Sub ListBox_LifestyleStatus_Click()
- Dim selectedChoice As String ' Variable to store the user's choice
- With ListBox_LifestyleStatus
- .AddItem "Non-Active"
- .AddItem "Occasional"
- .AddItem "Regular"
- End With
- If ListBox_LifestyleStatus.ListIndex <> -1 Then ' Check if an item is selected
- selectedChoice = ListBox_LifestyleStatus.List(ListBox_LifestyleStatus.ListIndex) ' Store the selected choice
- Else
- MsgBox "Please select a lifestyle status." ' Display an error message if no item is selected
- End If
- ' Now you can use the selectedChoice variable for further processing or storing the value.
- ' Example: You can assign it to a different variable or use it in your code as needed.
- ' For example, if you have another variable called lifestyleChoice, you can assign the selectedChoice value to it:
- ' lifestyleChoice = selectedChoice
- End Sub
- Private Sub ListBox_SmokingStatus_Click()
- Dim selectedChoice As String ' Variable to store the user's choice
- With ListBox_SmokingStatus
- .AddItem "Non-Smoker"
- .AddItem "Occasional"
- .AddItem "Regular"
- End With
- If ListBox_SmokingStatus.ListIndex <> -1 Then ' Check if an item is selected
- selectedChoice = ListBox_SmokingStatus.List(ListBox_SmokingStatus.ListIndex) ' Store the selected choice
- Else
- MsgBox "Please select a smoking status." ' Display an error message if no item is selected
- End If
- ' Now you can use the selectedChoice variable for further processing or storing the value.
- ' Example: You can assign it to a different variable or use it in your code as needed.
- ' For example, if you have another variable called userChoice, you can assign the selectedChoice value to it:
- ' userChoice = selectedChoice
- End Sub
- Private Sub MultiPage1_Change()
- End Sub
- Private Sub optbAllergiesNo_Click()
- Dim Allergy As String
- Allergy = Me.optbAllergiesNo.Value
- End Sub
- Private Sub optbAllergiesYes_Click()
- Dim Allergy As String
- Allegy = Me.optbAllergiesYes.Value
- End Sub
- Private Sub optbAnyNo_Click()
- Dim med As String
- med = optbAnyNo.Value
- End Sub
- Private Sub optbAnyYes_Click()
- Dim med As String
- med = optbAnyYes.Value
- End Sub
- Private Sub optbDeclaration_Click()
- ' Assuming you have a CheckBox named "chkAgreeDeclaration"
- If Not optbDeclaration.Value Then
- MsgBox "Please check the declaration box to proceed.", vbExclamation
- optbDeclaration.Value = False ' Uncheck the option button
- End If
- End Sub
- Private Sub optbConsent_Click()
- ' Assuming you have a CheckBox named "optbConsent"
- If Not optbConsent.Value Then
- MsgBox "Please check the consent box to proceed.", vbExclamation
- optbConsent.Value = False ' Uncheck the option button
- End If
- End Sub
- Private Sub optbFemale_Click()
- Dim Gender As String
- Gender = Me.optbFemale.Value
- Gender = "Female"
- End Sub
- Private Sub optbHealthConAsthma_Click()
- Dim Asthama As String
- Asthama = optbHealthConAsthama.Value
- End Sub
- Private Sub optbHealthConCancer_Click()
- Dim None As String
- None = optbHealthConCancer.Value
- End Sub
- Private Sub optbHealthConDiabates_Click()
- Dim Diabetes As String
- Diabetes = optbHealthConDiabates.Value
- End Sub
- Private Sub optbHealthConHyper_Click()
- Dim Hyper As String
- Hyper = optbHealthConHyper.Value
- End Sub
- Private Sub optbMale_Click()
- Dim Gender As String
- Gender = Me.optbMale.Value
- Gender = "Male"
- End Sub
- Private Sub optbMedConYes_Click()
- Dim MedCon As String
- MedCon = "Yes"
- End Sub
- Private Sub optbMedConNo_Click()
- Dim MedCon As String
- MedCon = "No"
- End Sub
- Private Sub cmbPremium_Change()
- Dim selectedChoice As String ' Variable to store the user's choice
- With cmbPremium
- .AddItem "Base premium"
- End With
- If cmbPremium.ListIndex <> -1 Then ' Check if an item is selected
- selectedChoice = cmbPremium.Value ' Store the selected choice
- Else
- MsgBox "Please select a premium option." ' Display an error message if no item is selected
- End If
- ' Now you can use the selectedChoice variable for further processing or storing the value.
- ' Example: You can assign it to a different variable or use it in your code as needed.
- ' For example, if you have another variable called premiumChoice, you can assign the selectedChoice value to it:
- ' premiumChoice = selectedChoice
- End Sub
- Private Sub spinbYear_Change()
- Dim currentNumber As Double
- currentNumber = CDbl(txtYear.Value)
- currentNumber = currentNumber + 0.5
- txtNumber.Value = currentNumber
- End Sub
- Private Sub btnDecrease_Click()
- Dim currentValue As Double
- currentValue = CDbl(txtYear.Value)
- currentValue = currentValue - 0.5
- txtYear.Value = currentValue
- End Sub
- Private Sub txtAddress_Change()
- Dim Addres As String
- Addres = Me.txtAddress.Value
- End Sub
- Private Sub txtContactNo_Change()
- Dim num As String
- num = Me.txtContactNo.Value
- End Sub
- Private Sub txtDOB_Change()
- Dim DOB As Date
- Dim validDate As Boolean
- validDate = IsDate(Me.txtDOB.Value)
- If validDate Then
- DOB = CDate(Me.txtDOB.Value)
- ' Date is valid, you can use the DOB variable for further processing or storing the value.
- ' Example: You can assign it to a different variable or use it in your code as needed.
- ' For example, if you have another variable called dateOfBirth, you can assign the DOB value to it:
- ' dateOfBirth = DOB
- Else
- MsgBox "Invalid date. Please enter a valid date."
- Me.txtDOB.Value = ""
- Me.txtDOB.SetFocus
- End If
- End Sub
- Private Sub txtEmergencyNo_Change()
- Dim emnum As String
- emnum = Me.txtEmergencyNo.Value
- End Sub
- Private Sub txtFirstname_Change()
- Dim Name As String
- Name = Me.txtFirstname.Value
- End Sub
- Private Sub txtHKID_Change()
- Dim ID As String
- ID = Me.txtHKID.Value
- End Sub
- Private Sub txtOccupation_Change()
- Dim work As String
- work = Me.txtOccupation.Value
- End Sub
- Private Sub txtPayFreq_Change()
- Dim currentValue As Integer
- currentValue = CInt(txtPayFreq.Value) ' Assuming you have a TextBox named "txtPayFreq"
- ' Store the currentValue in a variable or perform any other desired actions
- ' For example, you can store it in a global variable or process it further
- End Sub
- Private Sub spinbPay_Change()
- Dim currentValue As Integer
- currentValue = CInt(txtPayFreq.Value) ' Assuming you have a TextBox named "txtPayFreq"
- ' Determine which spin button was clicked
- If spinbPay.Value > currentValue Then
- ' Increase button was clicked
- currentValue = currentValue + 1
- ElseIf spinbPay.Value < currentValue Then
- ' Decrease button was clicked
- currentValue = currentValue - 1
- End If
- ' Update the TextBox with the new value
- txtPayFreq.Value = currentValue
- End Sub
- Private Sub txtPlanDate_Change()
- Dim enteredDate As Date
- Dim isValidDate As Boolean
- ' Attempt to parse the entered text as a date
- On Error Resume Next
- enteredDate = CDate(txtPlanDate.Value)
- On Error GoTo 0
- ' Check if the entered date is valid
- isValidDate = (Err.Number = 0)
- If isValidDate Then
- ' Date is valid, perform desired actions or store the date
- ' You can replace the message box with your desired logic
- MsgBox "Entered date: " & enteredDate
- Else
- ' Invalid date entered, display message box and prompt for re-entry
- MsgBox "Invalid date entered. Please enter a valid date.", vbExclamation
- txtPlanDate.Value = ""
- txtPlanDate.SetFocus
- End If
- End Sub
- Private Sub txtYear_Change()
- Dim inputValue As Double
- Dim storedValue As Double
- inputValue = CDbl(txtYear.Value)
- storedValue = inputValue
- End Sub
- Private Sub UserForm_Activate()
- Call Add_SatusItems
- Call ListBox_SmokingStatus_Click
- Call ListBox_DrinkingStatus_Click
- Call ListBox_LifestyleStatus_Click
- Call cmbPlan_Change
- Call cmbPremium_Change
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement