Hi,
uhh I am trying around a couple of minutes now.
a could not figure it out.
how to cast in Jabaco from an base object to a derived specialised object?
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
Public Sub Command1_Click()
Dim b1 As CommandButton
Dim b2 As CommandButton
Dim obj As Object
b1 = Me.Command1
Msgbox b1.Caption
obj = b1 ' OK
b2 = obj ' no! of course this does not work:
'the error in english:
'Compile error. Class: 'Form1' line: 15
'Type mismatch. Found 'VB/CommandButton' but 'java/lang/Object' is required!
'the error in german:
'Fehler in 'Form1' Zeile 15
'Eine Konvertierung von 'VB/CommandButton' nach 'java/lang/Ojbect' ist nicht möglich!
'I think the translation should be the other way around isn't it?
'Eine Konvertierung von 'java/lang/Ojbect' nach 'VB/CommandButton' ist nicht möglich!
' But how to cast?
' Java-syntax would be something like:
'b2 = (Commandbutton)obj
' does not exist in Jabaco
' VB.NET-Syntax would be:
'b2 = DirectCast(obj, CommandButton)
'or
'b2 = TryCast(Obj, CommandButton)
' both does not exist in Jabaco
' i found also the cast- method
'b2 = System.getClass.cast(obj)
' but how to use it in Jabaco?
Msgbox b2.Caption
End Sub
|
many thanks in advance
greetings
OlimilO