I would like to create a menu dynamically that allows me to select a value 0 to 369…
I did it, but it seems quite long, can this be done more concisely? The code is too long to post, I got this message

“Your post is really, really long! Too long! The maximum number of characters allowed is 10000. That’s really long!”

370 items in a menu is a lot
Even breaking it into groups where you have a top level item with a submenu for the specific items
0 - 100
101 - 200
201 - 300
301 - 369
still leaves 100+ items in each sub menu
a slider with min = 0 and max = 369 might work more simply but I have no idea if that fits your UI

would it not be easier to simply have the user type in a 3 digiit number rather that have 36 menus with 10 submenus each?

remove all the code you have…
put this in the KEYDOWN event of the textfield

dim x as integer
if key=chrb(9) or key=chrb(10) or key=chrb(3) or key=chrb(8) or key=chrb(13) then return false
if key<"0" or key>"9" then return true
x= val(me.text+key)
if x<0 or x>369 then return true
return false

this will ONLY accept a number between 0 and 369 to be typed in

[quote=146997:@Lennox Jacob] dim x as integer
if key=chrb(9) or key=chrb(10) or key=chrb(3) or key=chrb(8) or key=chrb(13) then return false
if key<“0” or key>“9” then return true
x= val(me.text+key)
if x<0 or x>369 then return true
return false[/quote]

Copy the event

Delete the current TextField

Drag another one from the library

Paste back the Keydown event.

For whatever reason the textfield is corrupted in your project.

added this …
dim x as double
if key=chrb(9) or key=chrb(10) or key=chrb(3) or key=chrb(8) or key=chrb(13) then return false
if key<“0” or key>“9” then return true
x= val(me.text+key)
if x<0 or x>369 then return true
return false

Ran it in the IDE but could not input a point.

Compiled it, but could not input a point.

I tried this too
dim x as double
if key=chrb(9) or key=chrb(10) or key=chrb(3) or key=chrb(8) or key=chrb(13) then return false
if key<“0” or key>“9” then return true
x= Cdbl(me.text+key)
if x<0 or x>369 then return true
return false

If you wish to allow the use of normal editing keys such as the left and right arrow, delete, forward delete you may wish to go with something like this in the key down event.

[code] Dim n As Integer

n = asc(Key)
if n > 47 and n < 58 then // Check if a digit
return false
// check for left arrow, right arrow, delete, forward delete, tab key, minus sign and decimal point
elseif n = 28 or n = 29 or n = 8 or n = 127 or n = 9 or n = 45 or n = 46 then
return false
end if
beep // not a valid key so beep and return true so key is ignored
return true
[/code]
If you don’t want to allow minus signs then remove the “or n = 45” portion in the elseif above. Now the user can use the normal editing keys in the event they mistype a character.