Results 1 to 4 of 4

Thread: How Do I Limit the Input to an InputBox

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    How Do I Limit the Input to an InputBox

    Here's the InputBox I have in my app, I'd like to put a restriction on the amount of data entered.

    VB Code:
    1. ganswer = InputBox("New employee " & rs!firstname & " " & rs!lastName & " is not signed off in TK, override?", "", "Y")
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    Member
    Join Date
    May 2003
    Posts
    59
    Why not use MsgBox instead;

    VB Code:
    1. ganswer = MsgBox("New employee " & rs!firstname & " " & rs!lastName & " is not signed off in TK, override?", vbYesNo)
    Share what you know... Know what you share

    R.G. Brown
    Senior Software Engineer
    Intel Corporation

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Here's one way but I wouldn't be surprised if there was an API.

    VB Code:
    1. Dim bDone As Boolean
    2.     Dim strResp As String
    3.     Dim strDefault As String
    4.     Const LIMIT As Integer = 5
    5.    
    6.     Do While Not bDone
    7.         strResp = InputBox("Get input", "My Title", strDefault)
    8.         If Len(strResp) > LIMIT Then
    9.             If vbYes = MsgBox("Max length is " & LIMIT & ". Should I truncate your input?", vbQuestion + vbYesNo) Then
    10.                 strResp = Left$(strResp, LIMIT)
    11.                 bDone = True
    12.             Else
    13.                 strDefault = strResp
    14.             End If
    15.         Else
    16.             bDone = True
    17.         End If
    18.     Loop

  4. #4
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    I guess I haven't posted anything interesting here for a while...
    Attached Files Attached Files
    Please rate my post.

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