JeffGates
Technical User
- May 11, 2002
- 6
Good evening folks.
Question: Is there a max lenght for the 'String' data type that can be entered by a user into an input box?
Explanation:
I'm trying to load Gift Card Numbers (16 characters each) into an inventory spreadsheet via an input box, code as follows:
Sub InputGiftCard()
Dim NumInput As String
Dim aCell As Range
Set aCell = Range("B65536").End(xlUp)
With aCell
.Offset(1, 0).Value = Date & " " & Time
.Offset(1, 1).Value = Range("GCOpResult")
.Offset(1, 2).Value = Range("GCOpAmt")
.Offset(1, 4).Value = "Active"
End With
NumInput = InputBox(Prompt:="Please Swipe Gift Card", Title:="Enter Gift Card Number")
If NumInput = vbNullString Then
aCell.Offset(1, 0).ClearContents
With aCell
.Offset(1, 1).ClearContents
.Offset(1, 2).ClearContents
.Offset(1, 4).ClearContents
End With
MsgBox ("You must swipe a gift card")
Exit Sub
Else
aCell.Offset(1, 3).Value = NumInput
End If
End Sub
The user can enter a 15 character string with no problem, but if the string exceeds 15 characters each of the additional characters are input into the sheet as zero.
Any suggestions?
Question: Is there a max lenght for the 'String' data type that can be entered by a user into an input box?
Explanation:
I'm trying to load Gift Card Numbers (16 characters each) into an inventory spreadsheet via an input box, code as follows:
Sub InputGiftCard()
Dim NumInput As String
Dim aCell As Range
Set aCell = Range("B65536").End(xlUp)
With aCell
.Offset(1, 0).Value = Date & " " & Time
.Offset(1, 1).Value = Range("GCOpResult")
.Offset(1, 2).Value = Range("GCOpAmt")
.Offset(1, 4).Value = "Active"
End With
NumInput = InputBox(Prompt:="Please Swipe Gift Card", Title:="Enter Gift Card Number")
If NumInput = vbNullString Then
aCell.Offset(1, 0).ClearContents
With aCell
.Offset(1, 1).ClearContents
.Offset(1, 2).ClearContents
.Offset(1, 4).ClearContents
End With
MsgBox ("You must swipe a gift card")
Exit Sub
Else
aCell.Offset(1, 3).Value = NumInput
End If
End Sub
The user can enter a 15 character string with no problem, but if the string exceeds 15 characters each of the additional characters are input into the sheet as zero.
Any suggestions?