# if x is less than y

a variable X (text input field) will be between 1-9
or it will be between 10-16

if X is 1-9 (or less than 10 however you want to say it)
then I need to make Y (a string) “00”

if X is 10-16
then I need to make Y “0”

how do I do this.
thanks for any help

Use an if statement like

```if x >0 and x<10 then mystring = "00" end if```

Do you want

TheString = format(x,“000”)

so that all the numbers end up as 3 digits?

michel cool will this work

[code]if x >0 and x<10 then
mystring = “00”
else
mystring = “0”
end if

[/code]

a variable X (text input field) will be between 1-9

so you don’t need if x >0

[quote=225893:@Jeff Tullin]a variable X (text input field) will be between 1-9

so you don’t need if x >0[/quote]

Unless additional data validation on input, count on the universe to have an idiot throw sand in the gears…

here is what I wrote, does not work
says mystring does not exist

[code] If ComboBox1.text = “AXS- Access Promos” then

``````if TextField_CD.Text  < "10" then
Dim mystring as string = "00"
else
Dim mystring as string = "0"
end

MsgBox  field + mystring + TextField_CD.Text + Chr(13) + field + "_" +  TextField_CD.Text + "_" + TextField_CUT.Text[/code]``````

do I need to convert the 10 to an integer NOT a string

``````dim Y as string
if bin(x).Len > 3 then Y = "0" else Y = "00"`````` or shorter:

``` dim Y as string Y = "0" + If(bin(x).Len > 3),"0","")```

not tested in IDE…

error says mystring does not exist

``` if bin(TextField_CD.Text).Len > 3 then mystring = "0" else mystring = "00" ```

Shawn, you need to dim your vars first!
And X is of course your NameOfEditfield.Text

says my string does not exist

[code] If ComboBox1.text = “AXS- Access Promos” then
if (TextField_CD.Text) < “10” Then
dim mystring as string = “0”
else
dim mystring as string = “00”
end if

``````MsgBox  field + mystring + TextField_CD.Text + Chr(13) + field + "_" +  TextField_CD.Text + "_" + TextField_CUT.Text
``````

End If[/code]

Quite good Shawn, I see you are new to Xojo so welcome aboard first.
May I would suggest you to take a look into this superb eBook?

[code] If ComboBox1.text = “AXS- Access Promos” then

``````if (TextField_CD.Text) < "10" Then
//this works
MsgBox "00 " + TextField_CD.Text
end if

//this does not, says s does not exits
MsgBox  field + s + TextField_CD.Text + Chr(13) + field + "_" +  TextField_CD.Text + "_" + TextField_CUT.Text
``````

End If[/code]

thanks tomas, already got it, and many other too, need to read them all.

got it to work

[code] If ComboBox1.text = “AXS- Access Promos” then

``````if (TextField_CD.Text) < "10" Then
//this works
MsgBox  field + "00" + TextField_CD.Text + Chr(13) + field + "_" +  TextField_CD.Text + "_" + TextField_CUT.Text
else
MsgBox  field + "0" + TextField_CD.Text + Chr(13) + field + "_" +  TextField_CD.Text + "_" + TextField_CUT.Text
end if
``````

End If[/code]

code < “10” Then
dim mystring as string = “0”
else[/code]
The reason that code did not work is because you dimmed your variable inside the conditional. If…then…else
Once that conditional finished, your var. ceased to exist.
Dim your var. before the conditional then just do assignment within the cond.

Obviously you really need to read the first one
Introduction to Programming with Xojo

it will save you a world of confusion.

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

[code] If ComboBox1.text = “AXS- Access Promos” then

``````if "0">(TextField_CD.Text)  and (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

else
dim mystring as string = "0"
MsgBox  field + mystring + TextField_CD.Text + Chr(13) + field + "_" +  TextField_CD.Text + "_" + TextField_CUT.Text

end if
``````

End If[/code]