Posted: Fri Jan 10, 2020 9:59 pm Post subject: For each, TypeOf and toInt16 in CE Lua
Let say I have 8 combo boxes in a form, each CB contains item 0 and 1, with each index start as default -1. Not created using table.
Now, I want to check if each CB index position is 0 (or the item is 1). I can use the traditional way by :
Code:
if cb1.itemIndex == 0 or cb2.itemIndex == 0.....'till cb8 then
-- do something
end
But I want like this in VB :
Code:
For Each ctl As Control In Me.Controls
If TypeOf ctl Is ComboBox Then
If ctl.Text = "1" Then
total += Convert.ToInt16(ctl.Tag)
End If
binary.Text += ctl.Text
End If
Next
Questions:
1. How to check if components is a CB using typeOf iin CE Lua?
2. Which CE Lua function to convert string/num to Int16?
3. What 'Tag' usefor in form designer?.
Thank you _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Last edited by Corroder on Sat Jan 11, 2020 4:18 am; edited 1 time in total
Thanks, DB, I will try. Meanwhile I use something like this:
Code:
function Check()
labelBin.Caption = 'Binary -' -- a label for binary value
labelDen.Caption = 'Denary -' -- a label for denary value
for i=1,8,1 do
local x = 'cb'..i --- combobox name are cb1, cb2..cb8
local t = x.Tag --- each cb have tag (number 2,4,8,16,32,64,128)
if x.itemIndex == 0 then
total = total + tonumber(t,16) -- convert tag to int16, is it true?
end
labelBin.Caption = x.Item -- need make math addition for value from each combobox
end
end
My goal is to create a game for a math course and the project name is Binary Calculation Game (I did it in VBNet script).
I just want to try re-make it using CE Lua.
Capture.JPG
Description:
Binary Calculation Game
Filesize:
33.15 KB
Viewed:
1358 Time(s)
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum