aijemkcaj Posted October 7, 2011 Posted October 7, 2011 i have a problem guys,i have a project and i really don't know how to convert binary to octal octal to binary hex to binary dec to binary using VB 2010.. i really need your help guys who knows the codes for this,i think its loop but i'm a newbie in any kinds of VB..our teacher didn't teach us how to do this so i'm counting on you guys who are expert in programming..i try to search in the internet but still i didn't find the codes..please help me guys,i only have 3 days left to pass my project..:(:(:( please help guys... Quote
Napivo1972 Posted October 7, 2011 Posted October 7, 2011 I will give you a hand but will not write the code for you... Let's take an easy example. 255 we all know that translates into 1111 1111 and FF but why? 255 / 2 = 127 rest 1 127/ 2 = 63 rest 1 63 / 2 = 31 rest 1 31 / 2 = 15 rest 1 15 / 2 = 7 rest 1 7 / 2 = 3 rest 1 3 / 2 = 1 rest 1 1 / 2 = 0 rest 1 Easy? This works for every other system you can up with 255 / 16 = 15 rest 15 = F 15 / 16 = 0 rest 15 = F 255 / 8 = 31 rest 7 31 / 8 = 3 rest 7 7 / 8 = 3 rest 3 Just remember to add the results from back to front. It makes sense as you do that for decimal numbers too so the octal of 255 is 377 not 773 Now the inverse should be easy too 377 octal 7 * 1 = 7 7 * 8 = 56 3 * 8 * 8= 192 7 + 56 + 192 = 255 note that the sequence of numbers I multiply with is 8 ^ 0 = 1 8 ^ 1 = 8 8 ^ 2 = 8 * 8 = 64 that counts for binary too 2 ^ 0 = 1 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 and for hexadecimal 16 ^ 0 = 1 16 ^ 1 = 16 16 ^ 2 = 255 We start here with the last char and not the first. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.