[code] If ComboBox1.text = “AXS- Access Promos” then
if (TextField_CD.Text) < “10” then
dim mystring As string = “00”
MsgBox field + mystring + TextField_CD.Text + Chr(13) + field + “" + TextField_CD.Text + "” + TextField_CUT.Text
if (TextField_CD.Text) > "9" then
dim mystring2 As string = "0"
MsgBox field + mystring2 + TextField_CD.Text + Chr(13) + field + "_" + TextField_CD.Text + "_" + TextField_CUT.Text
end
end
[quote]if CD=1 it works I get 001
if CD=2-9 it DOES NOT WORK, I get 02,03,04 instead of 002,003,004
if CD=10 it works I get 010,011,012[/quote]
“2” is less than “20”
“6” is greater than “20”
because they are strings, and it compares the characters , not the value
Turn the text into an integer first
dim v as integer
v = val(TextField_CD.Text)
msgbox MsgBox field + format(v,"000") + Chr(13) // ...etc
//the format statement does what you want.. you always get 3 digits
No harm in starting up. We all did. But it is of major importance that you get a sound grasp of the fundamentals, to avoid a life of pain and confusion. Sure, Xojo will let you do all sorts of things without reading anything, but that will come back to haunt you at every corner later.
In particular, it is paramount you wrap your head about variable types and scope. Otherwise, you will end up like here stumbling on a very basic snippet.