How can I WITHOUT USING THE VB COMPABILITY NAMESPACE get it's binary representation? For example : 3021 would turn into 101111001101
tks :D
Printable View
How can I WITHOUT USING THE VB COMPABILITY NAMESPACE get it's binary representation? For example : 3021 would turn into 101111001101
tks :D
Hi.
Something like this, should do it.
This uses a 16 bit value, hence the value of 15, but you can just as well use 31 instead of 15 to use a 32 bit value.
VB Code:
Dim S as String Dim I as Integer For I=15 To 0 Step -1 If (Value And 2^I)=2^I Then S &= "1" Else S &= "0" End If Next
I posted a function in this thread that converts signed long integers. Not sure what you'd need to do to modify it for .NET though.
http://www.vbforums.com/showthread.p...hreadid=282094
VB Code:
Dim val() As Integer = {1} Dim x As New BitArray(val) Dim strOut As String For i As Integer = 0 To x.Count - 1 strOut &= IIf(x.Item(i), "1", "0") Next Debug.WriteLine(StrReverse(strOut))
PT Exorcist, is this related to your thread where 4635 = 18,27? If so, you don't need to go through all that trouble
VB Code:
Dim port As Integer = 4635 MessageBox.Show(Decimal.Truncate(port / 256)) MessageBox.Show(port Mod 256)
You rule so much :D Ill try it now.