Android Question How to get a value from a class module

clooney48

Active Member
Licensed User
Longtime User
This is probably a dull question but I don´t know how to get a value from a class module. The normal way doesn´t work (Modulname.value).
I use the ClsWheel calendar example which has a class "ClsWheel". In this class there is a sub "Sub GetTimeHM" from where I would like to get the value "TimeTicks" to use it in "Main". Hope it is clear.

B4X:
Private Sub GetTimeHM(Time1 As String) As String
    Dim TimeFormat, Time2 As String
    Dim TimeTicks As Long
   
    TimeFormat = DateTime.TimeFormat
    DateTime.TimeFormat = "HH:mm"
   
    TimeTicks = DateTime.TimeParse(Time1) '<<<<<<
    DateTime.TimeFormat = TimeFormat
    Time2 = DateTime.TIME(TimeTicks)
    Return Time2
End Sub
 

clooney48

Active Member
Licensed User
Longtime User
I don´t get it. I have now the follwing code:

B4X:
'Class Module 'ClsWheel'

Public Sub GetDate(Date1 As String) As String
    Dim DateFormat, Date2 As String
    Dim DateTicks As Long
  
    DateFormat = DateTime.DateFormat
    DateTime.DateFormat = "yyyy MMMM dd"
  
    DateTicks = DateTime.DateParse(Date1)
    DateTime.DateFormat = DateFormat
    Date2 = DateTime.DATE(DateTicks)
    Return Date2
End Sub

'----------------
'Main Module

sub test
   msgbox(ClsWheel.DateTicks,"")

end sub

Erro Msg: Undeclared variable 'clswheel' is used
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
What exactly do you want ?
In your first post you are refering to PrivateSub GetTimeHM.
In your second post you are refering to PublicSub GetDate.
And you try to call a routine ClsWheel.DateTicks which doesn't exist in the ClsWheel class.
Please explain what exactly you want and I'll have a look at it.
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
Sorry for confusion! I use both "Sub" but I did the test only for "Public Sub GetDate".
So I would like to get in the Main module the value of DateTicks from the ClsWheel class.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should use Show2("EventName", DefaultValue) where you define an Event which returns the value t hatis a string and from this you can get the Ticks.
In the calling module define an event routine
Sub EventName_Closed(Canceled As Boolean, Selection As String)
Set EventName to the name of the wheel.
 
Upvote 0
Top