The online racing simulator
VB .NET typecasting problem
(3 posts, started )
VB .NET typecasting problem
Hi, I want to try and write some InSim stuff in VB .NET, since VS2k5 Express is free and all that, but I have a problem.

In my InSimInit class I have


Public port As Integer

and when send it it still shows as e.g. 29999, 5-bytes in length. I've tried Convert.ToUInt16 and some other stuff but I can't get it to become 2-bytes in length

How do I convert the port to the InSim word? Also, I don't think Convert.ToByte is working with flags and nodesecs

Thanks for your help
#2 - Stuff
Hmm.. what I do in VB6 is when filling out the packet to be sent I make the port 2 bytes instead an integer. Since VB bytes are the only unsigned data types it tends to work better. Something like..

Packet.Port(0) = intPort Mod 256
Packet.Port(1) = intPort \ 256

Might work for ya.
Yeah seems to be working finally. Thanks!

VB .NET typecasting problem
(3 posts, started )
FGED GREDG RDFGDR GSFDG