How I can promote the inputbox again when the user did not input the value in the inputbox?
Code:nolot = InputBox("Sila Masukkan No Lot", "Carian No Lot")
If Len(nolot) = 0 Then
MsgBox "Please input no lot"
Else
MsgBox "tahniah"
End If
End Sub
Printable View
How I can promote the inputbox again when the user did not input the value in the inputbox?
Code:nolot = InputBox("Sila Masukkan No Lot", "Carian No Lot")
If Len(nolot) = 0 Then
MsgBox "Please input no lot"
Else
MsgBox "tahniah"
End If
End Sub
You could do so with a Do Loop which checks nolot but then the user will be locked in an infinite loop until he enters valid data. It would be better to create your own input form which allows the user to select Cancel which you will then process accordingly.
I am still new.. Do loop?
Could you please show me the sintax how do loop work?have a sample?
calll it again with: nolot
Code:Do
nolot = InputBox("Sila Masukkan No Lot", "Carian No Lot")
If Len(nolot) = 0 Then MsgBox "Please input no lot"
Loop Until Len(nolot) > 0
Add a form to the project.
Put a label, a textbox and two command buttons on the form. Make the caption of one button "OK" and the other one "Cancel". In a module put:
Public bCancel As Boolean
Public sInput As String
In your program, set the form's caption to "Carian No Lot" (frmMain.Caption = "Carian No Lot") , its label to "Sila Masukkan No Lot" (frmMain.Label1.Caption = "Sila Masukkan No Lot"), set bCancel to False and show the form modal (frmInput.Show vbModal).
In the input form's code, if the user clicks the cancel button, set bCancel to True. If he clicks the OK button, set sInput to what's in the textbox.
If either button is clicked, unload the form (Unload Me).
Back in your main program, if bCancel is True, the user wants to cancel, otherwise his answer is in sInput.
You can make the form look like a standard InputBox or anything else you prefer.