Convert integer to single problem

• Question

• User1119492014 posted

Hi, how do I convert my integer to single?

My single :
dim mySingle() as single

My integer :
dim myInteger as integer = 200

mySingle() = {200} works fine but not mySingle() = myInteger .... why?

Monday, April 14, 2008 1:31 PM

• User-1614311312 posted

Mysingle is array of type single.while myinteger is simply an variable of type integer.

So array type cannot be converted into a variable.

• Marked as answer by Thursday, October 7, 2021 12:00 AM
Wednesday, April 16, 2008 6:36 AM

All replies

• User-691438185 posted

MGK Sweden,

Actually there are many overload methods in Convert.ToSingle method. For example, ToSingle(Int16) converts the value of the specified 16-bit signed integer to an equivalent single-precision floating point number; ToSingle(Int32) converts the value of the specified 32-bit signed integer to an equivalent single-precision floating point number. Please use the proper ToSingle method overload according to your current scenario. The following link shows you the way:

Wednesday, April 16, 2008 2:43 AM
• User-1614311312 posted

Mysingle is array of type single.while myinteger is simply an variable of type integer.

So array type cannot be converted into a variable.

• Marked as answer by Thursday, October 7, 2021 12:00 AM
Wednesday, April 16, 2008 6:36 AM