我使用大数字(18位数),所以我将它存储到长变量中。 我在计算中发现了一些不当行为,因此我做了一个简单的测试程序。
计算不起作用,因为大数字应该... 更精确的是它链接到我用于存储的Map。 有什么建议吗?
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim b1,b2,b3 As Button
Dim MapData As Map
End Sub
Sub Activity_Create(FirstTime As Boolean)
b1.Initialize("Set100")
b1.Text="Set100"
Activity.AddView(b1,10%x,10%y,80%x,20%y)
b2.Initialize("SetBig")
b2.Text="SetBig"
Activity.AddView(b2,10%x,40%y,80%x,20%y)
b3.Initialize("Increase")
b3.Text="long++"
Activity.AddView(b3,10%x,70%y,80%x,20%y)
MapData.Initialize
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Set100_Click
Dim l As Long
l = 100
Log("set to: " & l)
MapData.Put("Token",l)
End Sub
Sub SetBig_Click
' long range: -9223372036854775808 to 9223372036854775807
Dim l As Long
l = 640345893847300380
Log("set to: " & l)
MapData.Put("Token",l)
End Sub
Sub Increase_Click
Dim l As Long
l = MapData.Get("Token")
Log("from map: " & l)
l = l + 1
Log("new val : " & l)
MapData.Put("Token",l)
End Sub
答案 0 :(得分:0)
你是对的。从未知对象到Long的转换中存在一个错误,导致此错误。此错误将在下次更新中修复。 在此期间,您可以创建自定义类型并将其存储。
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim b1,b2,b3 As Button
Dim MapData As Map
Type MyLong(l As Long)
End Sub
Sub Activity_Create(FirstTime As Boolean)
b1.Initialize("Set100")
b1.Text="Set100"
Activity.AddView(b1,10%x,10%y,80%x,20%y)
b2.Initialize("SetBig")
b2.Text="SetBig"
Activity.AddView(b2,10%x,40%y,80%x,20%y)
b3.Initialize("Increase")
b3.Text="long++"
Activity.AddView(b3,10%x,70%y,80%x,20%y)
MapData.Initialize
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Set100_Click
Dim l As Long
l = 100
Log("set to: " & l)
MapData.Put("Token",l)
End Sub
Sub SetBig_Click
' long range: -9223372036854775808 to 9223372036854775807
Dim l As MyLong
l.l = 640345893847300380
Log("set to: " & l)
MapData.Put("Token",l)
End Sub
Sub Increase_Click
Log(MapData.Get("Token"))
Dim l As MyLong
l = MapData.Get("Token")
l.l = l.l + 1
'If you want to create a copy of the original MyLong object:
Dim l2 As MyLong
l2.l = l.l
Log("new val : " & l.l)
MapData.Put("Token",l2)
End Sub