You are not logged in.

FrancoAA

Beginner

  • "FrancoAA" is male
  • "FrancoAA" started this thread

Posts: 15

Date of registration: May 4th 2010

Location: Rosario, Argentina

  • Send private message

1

Friday, July 23rd 2010, 8:25pm

instanceOf for jabaco

Google translate:Here is a small example of how to simulate the java instanceof operator, your comments and suggestions are welcome, greetings.

Original text:
Aquí les dejo un pequeño ejemplo de como simular el operador de java instanceof, sus comentarios y sugerencias serán bienvenidas, saludos.


Source code

1
2
3
Public Function InstanceOf(cls As Class, obj As Object) As Boolean
    InstanceOf = cls.isInstance(obj)
End Function


How to use it:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Dim num, dbl, str	num = 124	dbl = 124.333
str = "Hello world!"
Debug.Print("de que tipo es num?")
Debug.Print(InstanceOf(java#lang#String.class, num))
Debug.Print(InstanceOf(java#lang#Double.class, num))
Debug.Print(InstanceOf(java#lang#Integer.class, num))
Debug.Print("De que tipo es dbl?")
Debug.Print(InstanceOf(java#lang#String.class, dbl))
Debug.Print(InstanceOf(java#lang#Double.class, dbl))
Debug.Print(InstanceOf(java#lang#Integer.class, dbl))
Debug.Print("de que tipo es str?")
Debug.Print(InstanceOf(java#lang#String.class, str))
Debug.Print(InstanceOf(java#lang#Double.class, str))
Debug.Print(InstanceOf(java#lang#Integer.class, str))

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Saturday, July 24th 2010, 6:36pm

Hi,
have a look at this ancient thread:
TypeOf Is

regards
OlimilO

Rate this thread
WoltLab Burning Board