Re: Integers in a textbox
Would this work for you?
GIS.Value = Format(GIS.Value, "R000000000")
Re: Integers in a textbox
What kind of control is GIS? :confused:
Re: Integers in a textbox
textbox
And I dont know about that format command, because if the value in gis ='s 4 digits then there has to be "R + 5 zeros" is the gis ='s 5 digits then it has to be "R + 4 zeros"
Re: Integers in a textbox
Quote:
Originally Posted by cid
textbox
If GIS is a textbox, then your first problem is that textbox's don't have a Value property. They have Text property. GIS.Value itself should be throwing an error.
Re: Integers in a textbox
this is VBA(Sorry i should have clarified that)
And I believe in vba a textbox has the value property. Correct me if im wrong though.
Re: Integers in a textbox
Quote:
Originally Posted by cid
this is VBA(Sorry i should have clarified that)
And I believe in vba a textbox has the value property. Correct me if im wrong though.
I believe you are correct. Having said that, however, if your post remained in ClassicVB, you would be getting other possible comments or solutions to your problem, with VB6 code, that wouldn't work (like mine) because you are using VBA.
Therefore, I've moved this to Office Development.
Re: Integers in a textbox
ok, thanks... any other information on my problem would be helpful.
Thanks guys.
Re: Integers in a textbox
Try a formula like this:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim a As String, s As String
a = "124"
s = "R" & String$(10 - Len(a), "0") & a
MsgBox s & " " & Len(s)
End Sub
You might want to adjust the number 10 to suite your needs. This uses 11 digits each time.
EDIT: Just noticed the move. Hope VBA has the String$ command. I believe that it does, though.
Re: Integers in a textbox
im a little new but from looking at that code i gather...
A is a set variable that is equal to 124, and s is a string that inserts R and 11 zeros infront of the variable a?
I need to be able to insert "R0000" infront of a 5 digit number(random) and insert "R00000" infront of a 4 digit number. So I am not sure if your code will work with my needs.
Re: Integers in a textbox
you could add a function that will convert your input value to a string of 11 characters. Then in the _change event of the textbox call that function.
Function Code
VB Code:
Function Cid(Value As String) As String
Const Prefix As String = "R0000000000"
Cid = Left(Prefix, 11 - Len(Value)) & Value
End Function
_Change event code
VB Code:
Private Sub TextBox1_Change()
TextBox1.Value = Cid(TextBox1.Value)
End Sub
Re: Integers in a textbox
VB Code:
GIS.Value=Format$(GIS.Value,"R000000000")