Oct 27th, 2006, 01:21 PM
#1
Thread Starter
Addicted Member
[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!
Oct 27th, 2006, 01:54 PM
#2
Hyperactive Member
Re: Making InputBox longer?
Split the number up into lines
VB Code:
InputBox "Please input the following number" _
& vbCrLf & "123123123123123123123123123123123" _
& vbCrLf & "123123123123123123123123123123123" _
& vbCrLf & "123123123123123123123123123123123"
Oct 27th, 2006, 02:51 PM
#3
Thread Starter
Addicted Member
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 .
Oct 27th, 2006, 03:24 PM
#4
Re: Making InputBox longer?
Here's a quick workaround:
VB Code:
Dim tmp1 As String
Dim tmp2 As String
tmp1 = "3498302938349830293834983029383498" & _
"302938349830293834983029383498302" & _
"938349830293834983029383498302938" '100 characters
tmp2 = InputBox(Left(tmp1, 34) & vbCrLf & Mid(tmp1, 33, 33) & vbCrLf & Right(tmp1, 33), "Is it OK?", "0")
Attached Images
Oct 27th, 2006, 03:34 PM
#5
Thread Starter
Addicted Member
Re: Making InputBox longer?
How would I do that when I don't know the number, though? (as in my last post)
Oct 27th, 2006, 03:36 PM
#6
Re: Making InputBox longer?
How about a small function to wrap long lines:
VB Code:
IntakeUserNumber = InputBox(SplitString("Please input the following number: " & TotNumberInput))
Private Function SplitString(ByVal sString As String, Optional lLen As Long = 25) As String
Dim lCount As Long
If Len(sString) <> 0 Then
For lCount = 1 To Len(sString) \ lLen
SplitString = SplitString & Left$(sString, lLen) & vbCrLf
sString = Right$(sString, Len(sString) - lLen)
Next lCount
SplitString = SplitString & sString
End If
End Function
Oct 27th, 2006, 03:59 PM
#7
Thread Starter
Addicted Member
Re: Making InputBox longer?
Works perfect! If only I could understand the code, heh.
Thanks a lot
Oct 27th, 2006, 04:03 PM
#8
Re: Making InputBox longer?
Originally Posted by
Arby
Works perfect! If only I could understand the code, heh.
Thanks a lot
Commented version below
VB Code:
Private Function SplitString(ByVal sString As String, Optional lLen As Long = 25) As String
Dim lCount As Long
If Len(sString) <> 0 Then 'Check for vbNullString (avoids divide by zero).
For lCount = 1 To Len(sString) \ lLen 'The math determines the number of full chunks (int divide)
'and then loops that many times.
SplitString = SplitString & Left$(sString, lLen) & vbCrLf 'Add the current chunk to the output string.
sString = Right$(sString, Len(sString) - lLen) 'Remove it from the input string.
Next lCount
SplitString = SplitString & sString 'If there's anything left in the input, tack it on the output.
End If
End Function
Oct 27th, 2006, 04:12 PM
#9
Thread Starter
Addicted Member
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
Forum Rules
Click Here to Expand Forum to Full Width