Question Convertion vb to vb.net

swapnil24

New member
Joined
Feb 17, 2012
Messages
2
Programming Experience
Beginner
Hello, I want to convert vb6.0 data type to vb.net. I tried it with decimal data type plz help me to convert following line in vb.net "dim totamt(1 to 20,100 to 200) as currency:GB_bonesrock:
 
Hi,

In VB.NET the Currency data type is not available and the ability to create arrays with a lower bound greater than zero has been removed. Have a look at this article:-

The lower bound for arrays is always zero in Visual Basic .NET

To declare your array with the correct number of elements you would need to use:-

VB.NET:
Dim myDecimalArray(0 To 19, 0 To 99) As Decimal
'or
Dim myDecimalArray(19, 99) As Decimal

I have seen ways to get round this limitation on the internet but I would suggest that you get used to adopting the new principals introduced with .NET

You can then assign a value to your array and display it in a currency format as follows:-

VB.NET:
myDecimalArray(0, 0) = CDec(14.5678)
MsgBox(myDecimalArray(0, 0).ToString("c"))

Hope that helps.

Cheers,

Ian
 
Last edited:
Back
Top