Results 1 to 9 of 9

Thread: [RESOLVED] Making InputBox longer?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Resolved [RESOLVED] Making InputBox longer?

    Hi all,

    Just a quick question - is it possible to force the size of inputbox to be longer, without having to make my own one as a form? To stop problems like this:



    I tried changing the XPos and YPos, but that's just the position of the inputbox on the screen....

    Thanks!

  2. #2
    Hyperactive Member
    Join Date
    Aug 2003
    Location
    Wigan, UK
    Posts
    291

    Re: Making InputBox longer?

    Split the number up into lines
    VB Code:
    1. InputBox "Please input the following number" _
    2.          & vbCrLf & "123123123123123123123123123123123" _
    3.          & vbCrLf & "123123123123123123123123123123123" _
    4.          & vbCrLf & "123123123123123123123123123123123"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: Making InputBox longer?

    Ah, but the number is randomly generated . The actual code is:

    Code:
    IntakeUserNumber = InputBox("Please input the following number: " & TotNumberInput)
    Maybe there's a way of cutting down the string into, say, 25-character chunks and displaying them on different lines?
    Last edited by BubbleLife; Oct 27th, 2006 at 03:01 PM.

  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Making InputBox longer?

    Here's a quick workaround:
    VB Code:
    1. Dim tmp1 As String
    2. Dim tmp2 As String
    3.  
    4. tmp1 = "3498302938349830293834983029383498" & _
    5.        "302938349830293834983029383498302" & _
    6.        "938349830293834983029383498302938" '100 characters
    7.  
    8. tmp2 = InputBox(Left(tmp1, 34) & vbCrLf & Mid(tmp1, 33, 33) & vbCrLf & Right(tmp1, 33), "Is it OK?", "0")
    Attached Images Attached Images  

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: Making InputBox longer?

    How would I do that when I don't know the number, though? (as in my last post)

  6. #6
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Making InputBox longer?

    How about a small function to wrap long lines:
    VB Code:
    1. IntakeUserNumber = InputBox(SplitString("Please input the following number: " & TotNumberInput))
    2.  
    3. Private Function SplitString(ByVal sString As String, Optional lLen As Long = 25) As String
    4.  
    5.     Dim lCount As Long
    6.    
    7.     If Len(sString) <> 0 Then
    8.         For lCount = 1 To Len(sString) \ lLen
    9.             SplitString = SplitString & Left$(sString, lLen) & vbCrLf
    10.             sString = Right$(sString, Len(sString) - lLen)
    11.         Next lCount
    12.  
    13.         SplitString = SplitString & sString
    14.     End If
    15.  
    16. End Function

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: Making InputBox longer?

    Works perfect! If only I could understand the code, heh.

    Thanks a lot

  8. #8
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Making InputBox longer?

    Quote Originally Posted by Arby
    Works perfect! If only I could understand the code, heh.

    Thanks a lot
    Commented version below
    VB Code:
    1. Private Function SplitString(ByVal sString As String, Optional lLen As Long = 25) As String
    2.  
    3.     Dim lCount As Long
    4.    
    5.     If Len(sString) <> 0 Then                           'Check for vbNullString (avoids divide by zero).
    6.         For lCount = 1 To Len(sString) \ lLen           'The math determines the number of full chunks (int divide)
    7.                                                         'and then loops that many times.
    8.             SplitString = SplitString & Left$(sString, lLen) & vbCrLf   'Add the current chunk to the output string.
    9.             sString = Right$(sString, Len(sString) - lLen)  'Remove it from the input string.
    10.         Next lCount
    11.  
    12.         SplitString = SplitString & sString             'If there's anything left in the input, tack it on the output.
    13.     End If
    14.  
    15. End Function

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: [RESOLVED] Making InputBox longer?

    Ahh.. Confusing, haha. Well, I'm only a VB beginner (everything I know about VB I learnt from a short unit in my BTEC...), and I suck at maths, soo.. heh. But thank you for commenting it anyway

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