[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:
http://www.arbital24.com/MakingProg/Erk.jpg
I tried changing the XPos and YPos, but that's just the position of the inputbox on the screen....
Thanks!
Re: Making InputBox longer?
Split the number up into lines
VB Code:
InputBox "Please input the following number" _
& vbCrLf & "123123123123123123123123123123123" _
& vbCrLf & "123123123123123123123123123123123" _
& vbCrLf & "123123123123123123123123123123123"
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?
1 Attachment(s)
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")
Re: Making InputBox longer?
How would I do that when I don't know the number, though? (as in my last post)
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
Re: Making InputBox longer?
Works perfect! If only I could understand the code, heh.
Thanks a lot :)
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:
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
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 :)