You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

A1880

Intermediate

  • "A1880" is male
  • "A1880" started this thread

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

1

Tuesday, July 28th 2009, 3:52pm

Automatic CStr() conversion of byte variables

Hi,
I noticed that "byte" variables are different from "integer" variable with respect to automatic conversion to String.

My test code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Private Sub toStringText
   Dim s As String 
   Dim b As Byte = 5
   Dim i As Integer = 6
   Dim ll As Long = 7
   Dim ib As Integer 
   
   debug.Print b         '  gives an unprintable character (ASCII code 5?)
   
   ib = b
   debug.Print ib
   
   s = b
   debug.Print s          '  gives an unprintable character (ASCII code 5?)
   
   s = i
   debug.Print s
   
   s = ll
   debug.Print s
End Sub


What Jabaco creates as Java code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
private static void toStringText() { Exception Err = null; Exception h2 = null;
    String s = "";
    byte b = (byte)5;
    int i = 6;
    long ll = 7;
    int ib = 0;

    Global.Debug().Print(String.valueOf(Conversion.CInt(b)));

    ib = Conversion.CInt(b);
    Global.Debug().Print(String.valueOf(ib));

    s = String.valueOf(Conversion.CInt(b));
    Global.Debug().Print(s);

    s = String.valueOf(i);
    Global.Debug().Print(s);

    s = String.valueOf(ll);
    Global.Debug().Print(s);
  }


My impression is that byte values are taken as ASCII character codes rather than as integer values.
In this respect, a byte is more a "char" than an "integer".

Greetings

A1880

Rate this thread
WoltLab Burning Board