Results 1 to 6 of 6

Thread: [RESOLVED] inputbox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] inputbox

    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

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: inputbox

    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.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: inputbox

    I am still new.. Do loop?

    Could you please show me the sintax how do loop work?have a sample?

  4. #4
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: inputbox

    calll it again with: nolot


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  5. #5
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: inputbox

    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

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: [RESOLVED] inputbox

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width