Variable

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have the following:

1 Dim bRows As Byte()
2 sRows.Read(bRows, 0, Integer.MaxValue)

On line 2 I get an warning saying:

"Variable bRows is used before it has been assigner a value"

How can I solve this?

And what is the difference between using:

Dim bRows As Byte()

And:

Dim bRows() As Byte

Thanks,

Miguel
 
shapper said:
Hello,

I have the following:

1 Dim bRows As Byte()
2 sRows.Read(bRows, 0, Integer.MaxValue)

On line 2 I get an warning saying:

"Variable bRows is used before it has been assigner a value"

How can I solve this?

By assigning it a value.

You have created a reference to a byte array, but you haven't created
the array.

Dim bRows As New Byte()
And what is the difference between using:

Dim bRows As Byte()

And:

Dim bRows() As Byte

There is no difference in result.

The first one is the new syntax that is logical in .NET, as the entire
data type comes after the As keyword.

The second one is the syntax inherited from earlier versions of VB,
where arrays was a special kind of variable instead of just a data type
like any other.
 
Back
Top