|
-
Jun 1st, 2007, 11:51 AM
#13
PowerPoster
Re: Denary (Base 10) to Binary (Base 2)
However, here's a more detailed version with the right stuff in there
Code:
Private Function den2bin(den As Double)
dim sta as double, x as string
'Sta = starting value. The value in this case is a 24-bit number and the value
'of the 25th bit...it is divided by 2 at each point and each successive number
'is the value of the next lowest bit...sta/2 is the 24th bit, /2 again is the 23rd
'until you get to 1 which is the 1st bit
sta = 16777216
For b = 1 To 24
sta = sta / 2
'X here is unimportant...it's a temporary string storing the binary data as it
'is being built
If den And sta Then x = x & "1" Else x = x & "0"
Next b
'This is how functions work. Notice how the first part "den2bin" is the name
'of this function...saying "den2bin = x" is saying to return the value of x as
'the returned value from the function...functions return values :-P
den2bin = x
End Function
Yes, I removed the step -1 and made it 1 to 24...I originally was going to use the original idea with the array but decided against it :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|