Help me :>) pls!!!!!!!!!!
Author Message
Help me :>) pls!!!!!!!!!!

I am new to VB and I have been trying to make a very simple beginners
program that will convert any inputted number into binary.

My coding sucks but I can get it to work in BASIC and not VB :<(.

Can someone send me a very simple program  No .exe file I wanna see the
codes and compare to see what I am doing wrong.

I know it's less than 10 lines of code but I just can't seem to get it to
work.

Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics in a 2D
world.

Fri, 01 Oct 2004 12:55:23 GMT
Help me :>) pls!!!!!!!!!!

Quote:
>I am new to VB and I have been trying to make a very simple beginners
>program that will convert any inputted number into binary.
>I know it's less than 10 lines of code but I just can't seem to get it to
>work.

Here is a better idea, post your ten lines and someone will point out
what you have done wrong.
The idea of the group is that everyone can see the other's problems
and the solvings of which of those and by whom.
Henry Blake eat your heart out. ;-)

Quote:
>Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics in a 2D
>world.

Look at DirectX.

Regards, Frank

Fri, 01 Oct 2004 13:23:10 GMT
Help me :>) pls!!!!!!!!!!
From a previous post of mine...

Rick

'Decimal To Binary
' =================
' NOTE: You can limit the size of the returned
'              answer by specifying the number of bits
Function Dec2Bin(ByVal DecimalIn As Variant, _
Optional NumberOfBits As Variant) As String
Dec2Bin = ""
DecimalIn = Int(CDec(DecimalIn))
Do While DecimalIn <> 0
Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) & Dec2Bin
DecimalIn = Int(DecimalIn / 2)
Loop
If Not IsMissing(NumberOfBits) Then
If Len(Dec2Bin) > NumberOfBits Then
Dec2Bin = "Error - Number exceeds specified bit size"
Else
Dec2Bin = Right\$(String\$(NumberOfBits, _
"0") & Dec2Bin, NumberOfBits)
End If
End If
End Function

Quote:
> I am new to VB and I have been trying to make a very simple beginners
> program that will convert any inputted number into binary.

> My coding sucks but I can get it to work in BASIC and not VB :<(.

> Can someone send me a very simple program  No .exe file I wanna see the
> codes and compare to see what I am doing wrong.

> I know it's less than 10 lines of code but I just can't seem to get it to
> work.

> Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics in a 2D
> world.

Fri, 01 Oct 2004 14:01:43 GMT
Help me :>) pls!!!!!!!!!!
Damn Rick .. you're scaring the hell out of the poor guy <g>

Shit, after rereading it you're scaing the hell out of me. <vbg>

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.

*BASIC: Briskly Achieved Solutions Impossible in C*

Quote:

> From a previous post of mine...

> Rick

> 'Decimal To Binary
> ' =================
> ' NOTE: You can limit the size of the returned
> '              answer by specifying the number of bits
> Function Dec2Bin(ByVal DecimalIn As Variant, _
>               Optional NumberOfBits As Variant) As String
>     Dec2Bin = ""
>     DecimalIn = Int(CDec(DecimalIn))
>     Do While DecimalIn <> 0
>         Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) &
> Dec2Bin         DecimalIn = Int(DecimalIn / 2)
>     Loop
>     If Not IsMissing(NumberOfBits) Then
>        If Len(Dec2Bin) > NumberOfBits Then
>           Dec2Bin = "Error - Number exceeds specified bit size"
>        Else
>           Dec2Bin = Right\$(String\$(NumberOfBits, _
>                           "0") & Dec2Bin, NumberOfBits)
>        End If
>     End If
> End Function

>> I am new to VB and I have been trying to make a very simple beginners
>> program that will convert any inputted number into binary.

>> My coding sucks but I can get it to work in BASIC and not VB :<(.

>> Can someone send me a very simple program  No .exe file I wanna see
>> the codes and compare to see what I am doing wrong.

>> I know it's less than 10 lines of code but I just can't seem to get
>> it to work.

>> Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics
>> in a 2D world.

Sat, 02 Oct 2004 06:45:27 GMT
Help me :>) pls!!!!!!!!!!
hehe can't make sense out of it :)

Quote:
> From a previous post of mine...

> Rick

> 'Decimal To Binary
> ' =================
> ' NOTE: You can limit the size of the returned
> '              answer by specifying the number of bits
> Function Dec2Bin(ByVal DecimalIn As Variant, _
>               Optional NumberOfBits As Variant) As String
>     Dec2Bin = ""
>     DecimalIn = Int(CDec(DecimalIn))
>     Do While DecimalIn <> 0
>         Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) &
Dec2Bin
>         DecimalIn = Int(DecimalIn / 2)
>     Loop
>     If Not IsMissing(NumberOfBits) Then
>        If Len(Dec2Bin) > NumberOfBits Then
>           Dec2Bin = "Error - Number exceeds specified bit size"
>        Else
>           Dec2Bin = Right\$(String\$(NumberOfBits, _
>                           "0") & Dec2Bin, NumberOfBits)
>        End If
>     End If
> End Function

> > I am new to VB and I have been trying to make a very simple beginners
> > program that will convert any inputted number into binary.

> > My coding sucks but I can get it to work in BASIC and not VB :<(.

> > Can someone send me a very simple program  No .exe file I wanna see the
> > codes and compare to see what I am doing wrong.

> > I know it's less than 10 lines of code but I just can't seem to get it
to
> > work.

> > Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics in a
2D
> > world.

Mon, 04 Oct 2004 10:59:56 GMT
Help me :>) pls!!!!!!!!!!
I know my If....Then staement sucks, pls tell me what's wrong.
The output sucks too, hehe, outputs 0-9 instead of just 0's and 1's.

Private Sub Command1_Click()

For Number = 8 To 1 Step -1
Binary = 2 ^ (Number - 1)               'Produces 8 bit numbers from 128-0
If Binary >= Val(Text1.Text) Then       'Text1.text is the inputted number
to convert
Text1.Text = Abs(bin - Val(Text1.Text))
Label1.Caption = bin & "0"          'Output of 0's in the label screen
Else
Label1.Caption = bin & "1"          'Output of 1's in the label screen
End If

Next Number

End Sub

Quote:
> I am new to VB and I have been trying to make a very simple beginners
> program that will convert any inputted number into binary.

> My coding sucks but I can get it to work in BASIC and not VB :<(.

> Can someone send me a very simple program  No .exe file I wanna see the
> codes and compare to see what I am doing wrong.

> I know it's less than 10 lines of code but I just can't seem to get it to
> work.

> Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics in a
2D
> world.

Mon, 04 Oct 2004 11:03:01 GMT
Help me :>) pls!!!!!!!!!!
Alright, let's boil my code down to the bare essentials. The following function will take
a whole number and convert it into its binary form. The binary number will only be as long
as is needed to show the value. That means there will be **no** leading zeroes to fill out
the binary value to an specific bit size (that is what the code I removed was in there
for). So

Debug.Print Dec2Bin(43)

will print out

101011

rather than

0000000000101011

if we assume it is a 16-bit value. The boiled down function is...

Function Dec2Bin(ByVal DecimalIn As Long) As String
Do While DecimalIn <> 0
Dec2Bin = Format\$(DecimalIn - _
2 * Int(DecimalIn / 2)) & Dec2Bin
DecimalIn = Int(DecimalIn / 2)
Loop
End Function

See if you can follow the logic for this. Note that I improved it a little by replacing
the Str function (which had to be Trim'med because it includes a leading blank space for
all positive numbers) with the Format\$ function (which does the same thing with including
the leading blank space). I also removed the CDec function, which allowed this function to
produce an answer up to 96-bits long, and made the argument a simple Long value. This
should reduce the complexity enough to allow you to follow the logic. If the logic still
isn't clear, try "walking" through the loop one iteration at a time (do it long-hand) to
watch how a number is processed.

Rick

Quote:
> hehe can't make sense out of it :)

> > From a previous post of mine...

> > Rick

> > 'Decimal To Binary
> > ' =================
> > ' NOTE: You can limit the size of the returned
> > '              answer by specifying the number of bits
> > Function Dec2Bin(ByVal DecimalIn As Variant, _
> >               Optional NumberOfBits As Variant) As String
> >     Dec2Bin = ""
> >     DecimalIn = Int(CDec(DecimalIn))
> >     Do While DecimalIn <> 0
> >         Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) &
> Dec2Bin
> >         DecimalIn = Int(DecimalIn / 2)
> >     Loop
> >     If Not IsMissing(NumberOfBits) Then
> >        If Len(Dec2Bin) > NumberOfBits Then
> >           Dec2Bin = "Error - Number exceeds specified bit size"
> >        Else
> >           Dec2Bin = Right\$(String\$(NumberOfBits, _
> >                           "0") & Dec2Bin, NumberOfBits)
> >        End If
> >     End If
> > End Function

> > > I am new to VB and I have been trying to make a very simple beginners
> > > program that will convert any inputted number into binary.

> > > My coding sucks but I can get it to work in BASIC and not VB :<(.

> > > Can someone send me a very simple program  No .exe file I wanna see the
> > > codes and compare to see what I am doing wrong.

> > > I know it's less than 10 lines of code but I just can't seem to get it
> to
> > > work.

> > > Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics in a
> 2D
> > > world.

Mon, 04 Oct 2004 12:58:40 GMT
Help me :>) pls!!!!!!!!!!
<g>

It's still much less intimidating than some of the API solutions you have posted in the
past. Now if you want to talk about "scary"...

Besides, I'm surprised you haven't grabbed this function for inclusion on your website.
After all, as written, it allows for values that are up to 96-bits in size. We are talking
of a 29-digit decimal digit here (same range restriction as for the Decimal data type).

Rick

Quote:
> Damn Rick .. you're scaring the hell out of the poor guy <g>

> Shit, after rereading it you're scaing the hell out of me. <vbg>

> --

> Randy Birch
> MVP Visual Basic
> http://www.mvps.org/vbnet/
> Please respond only to the newsgroups so all can benefit.

> *BASIC: Briskly Achieved Solutions Impossible in C*

> > From a previous post of mine...

> > Rick

> > 'Decimal To Binary
> > ' =================
> > ' NOTE: You can limit the size of the returned
> > '              answer by specifying the number of bits
> > Function Dec2Bin(ByVal DecimalIn As Variant, _
> >               Optional NumberOfBits As Variant) As String
> >     Dec2Bin = ""
> >     DecimalIn = Int(CDec(DecimalIn))
> >     Do While DecimalIn <> 0
> >         Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) &
> > Dec2Bin         DecimalIn = Int(DecimalIn / 2)
> >     Loop
> >     If Not IsMissing(NumberOfBits) Then
> >        If Len(Dec2Bin) > NumberOfBits Then
> >           Dec2Bin = "Error - Number exceeds specified bit size"
> >        Else
> >           Dec2Bin = Right\$(String\$(NumberOfBits, _
> >                           "0") & Dec2Bin, NumberOfBits)
> >        End If
> >     End If
> > End Function

> >> I am new to VB and I have been trying to make a very simple beginners
> >> program that will convert any inputted number into binary.

> >> My coding sucks but I can get it to work in BASIC and not VB :<(.

> >> Can someone send me a very simple program  No .exe file I wanna see
> >> the codes and compare to see what I am doing wrong.

> >> I know it's less than 10 lines of code but I just can't seem to get
> >> it to work.

> >> Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics
> >> in a 2D world.

Mon, 04 Oct 2004 13:03:13 GMT
Help me :>) pls!!!!!!!!!!
Thanks

If I can program like u folks out there I'd be rich.
I have a great idea for a game I need to master programming.

What programming language should I study C++ or VB for 3D games kinda like
Dark Age of Camelot and EverQuest that I am playing?

Quote:
> Alright, let's boil my code down to the bare essentials. The following
function will take
> a whole number and convert it into its binary form. The binary number will
only be as long
> as is needed to show the value. That means there will be **no** leading
zeroes to fill out
> the binary value to an specific bit size (that is what the code I removed
was in there
> for). So

>      Debug.Print Dec2Bin(43)

> will print out

>      101011

> rather than

>      0000000000101011

> if we assume it is a 16-bit value. The boiled down function is...

> Function Dec2Bin(ByVal DecimalIn As Long) As String
>     Do While DecimalIn <> 0
>         Dec2Bin = Format\$(DecimalIn - _
>                         2 * Int(DecimalIn / 2)) & Dec2Bin
>         DecimalIn = Int(DecimalIn / 2)
>     Loop
> End Function

> See if you can follow the logic for this. Note that I improved it a little
by replacing
> the Str function (which had to be Trim'med because it includes a leading
blank space for
> all positive numbers) with the Format\$ function (which does the same thing
with including
> the leading blank space). I also removed the CDec function, which allowed
this function to
> produce an answer up to 96-bits long, and made the argument a simple Long
value. This
> should reduce the complexity enough to allow you to follow the logic. If
the logic still
> isn't clear, try "walking" through the loop one iteration at a time (do it
long-hand) to
> watch how a number is processed.

> Rick

> > hehe can't make sense out of it :)

> > > From a previous post of mine...

> > > Rick

> > > 'Decimal To Binary
> > > ' =================
> > > ' NOTE: You can limit the size of the returned
> > > '              answer by specifying the number of bits
> > > Function Dec2Bin(ByVal DecimalIn As Variant, _
> > >               Optional NumberOfBits As Variant) As String
> > >     Dec2Bin = ""
> > >     DecimalIn = Int(CDec(DecimalIn))
> > >     Do While DecimalIn <> 0
> > >         Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) &
> > Dec2Bin
> > >         DecimalIn = Int(DecimalIn / 2)
> > >     Loop
> > >     If Not IsMissing(NumberOfBits) Then
> > >        If Len(Dec2Bin) > NumberOfBits Then
> > >           Dec2Bin = "Error - Number exceeds specified bit size"
> > >        Else
> > >           Dec2Bin = Right\$(String\$(NumberOfBits, _
> > >                           "0") & Dec2Bin, NumberOfBits)
> > >        End If
> > >     End If
> > > End Function

> > > > I am new to VB and I have been trying to make a very simple
beginners
> > > > program that will convert any inputted number into binary.

> > > > My coding sucks but I can get it to work in BASIC and not VB :<(.

> > > > Can someone send me a very simple program  No .exe file I wanna see
the
> > > > codes and compare to see what I am doing wrong.

> > > > I know it's less than 10 lines of code but I just can't seem to get
it
> > to
> > > > work.

> > > > Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics
in a
> > 2D
> > > > world.

Mon, 04 Oct 2004 13:15:51 GMT
Help me :>) pls!!!!!!!!!!
<g> I'll snag it then. Thanks

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.

*BASIC: Briskly Achieved Solutions Impossible in C*

Quote:
> <g>

> It's still much less intimidating than some of the API solutions you have
posted in the
> past. Now if you want to talk about "scary"...

> Besides, I'm surprised you haven't grabbed this function for inclusion on
> After all, as written, it allows for values that are up to 96-bits in

size. We are talking
Quote:
> of a 29-digit decimal digit here (same range restriction as for the
Decimal data type).

> Rick

> > Damn Rick .. you're scaring the hell out of the poor guy <g>

> > Shit, after rereading it you're scaing the hell out of me. <vbg>

> > --

> > Randy Birch
> > MVP Visual Basic
> > http://www.mvps.org/vbnet/
> > Please respond only to the newsgroups so all can benefit.

> > *BASIC: Briskly Achieved Solutions Impossible in C*

> > > From a previous post of mine...

> > > Rick

> > > 'Decimal To Binary
> > > ' =================
> > > ' NOTE: You can limit the size of the returned
> > > '              answer by specifying the number of bits
> > > Function Dec2Bin(ByVal DecimalIn As Variant, _
> > >               Optional NumberOfBits As Variant) As String
> > >     Dec2Bin = ""
> > >     DecimalIn = Int(CDec(DecimalIn))
> > >     Do While DecimalIn <> 0
> > >         Dec2Bin = Trim\$(Str\$(DecimalIn - 2 * Int(DecimalIn / 2))) &
> > > Dec2Bin         DecimalIn = Int(DecimalIn / 2)
> > >     Loop
> > >     If Not IsMissing(NumberOfBits) Then
> > >        If Len(Dec2Bin) > NumberOfBits Then
> > >           Dec2Bin = "Error - Number exceeds specified bit size"
> > >        Else
> > >           Dec2Bin = Right\$(String\$(NumberOfBits, _
> > >                           "0") & Dec2Bin, NumberOfBits)
> > >        End If
> > >     End If
> > > End Function

> > >> I am new to VB and I have been trying to make a very simple beginners
> > >> program that will convert any inputted number into binary.

> > >> My coding sucks but I can get it to work in BASIC and not VB :<(.

> > >> Can someone send me a very simple program  No .exe file I wanna see
> > >> the codes and compare to see what I am doing wrong.

> > >> I know it's less than 10 lines of code but I just can't seem to get
> > >> it to work.

> > >> Also can VB do 3D + 360 degree games?  I know VB can do 3D graphics
> > >> in a 2D world.

Tue, 05 Oct 2004 06:12:19 GMT
Help me :>) pls!!!!!!!!!!

Quote:
> <g> I'll snag it then. Thanks

On the off chance that you are serious, I've modified it here to use the Format\$ function
instead of the Str\$ imbedded within a Trim\$ (which was necessary in order to account for
Str\$ default action of putting a leading blank space on positive numbers; Format\$ doesn't
suffer from this "feature"). I've also provided the inverse (Bin2Dec) function which also
works with numbers up to 96-bits.

Rick

'Decimal To Binary
' =================
' NOTE: You can limit the size of the returned
'              answer by specifying the number of bits
Function Dec2Bin(ByVal DecimalIn As Variant, _
Optional NumberOfBits As Variant) As String
Dec2Bin = ""
DecimalIn = Int(CDec(DecimalIn))
Do While DecimalIn <> 0
Dec2Bin = Format\$(DecimalIn - 2 * Int(DecimalIn / 2)) & Dec2Bin
DecimalIn = Int(DecimalIn / 2)
Loop
If Not IsMissing(NumberOfBits) Then
If Len(Dec2Bin) > NumberOfBits Then
Dec2Bin = "Error - Number exceeds specified bit size"
Else
Dec2Bin = Right\$(String\$(NumberOfBits, _
"0") & Dec2Bin, NumberOfBits)
End If
End If
End Function

'Binary To Decimal
' =================
Function Bin2Dec(BinaryString As String) As Variant
Dim X As Integer
For X = 0 To Len(BinaryString) - 1
Bin2Dec = CDec(Bin2Dec) + Val(Mid(BinaryString, _
Len(BinaryString) - X, 1)) * 2 ^ X
Next
End Function

Tue, 05 Oct 2004 07:52:32 GMT

 Page 1 of 1 [ 11 post ]

Relevant Pages