home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2776
Discussions: 186,609, Posts: 2,227,069, Members: 230,244
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old July 9th, 2008, 12:05 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 1
VB.NET (binary to hexadecimal)

Any1 can help me to do some correction as when i run my programming, if i put 54 1's for my binary input. the out put were bcome an error. If less than 54 1's there were no error and can convert to hex. Is there any idea to create that i can input infinite binary and convert to hex?

Module Module1
Sub Main()
Dim s AsString
Dim formatStr AsString
Console.Write("Please enter a binary: ")
s = Console.ReadLine()
formatStr =
String.Format("hex number is:{0}", BinToHex(s))
Console.WriteLine(formatStr)
Console.ReadLine()
EndSub
Function BinToHex(ByVal BinNum AsString) AsString
Dim BinLen AsInteger, i AsDouble
Dim HexNum AsObject
OnErrorGoTo ErrorHandler
BinLen = Len(BinNum)
For i = BinLen To 1 Step -1
If Asc(Mid(BinNum, i, 1)) < 48 Or _
Asc(Mid(BinNum, i, 1)) > 49
Then
HexNum = ""
Err.Raise(1002, "BinToHex", "Invalid output")
EndIf
If Mid(BinNum, i, 1) And 1 Then
HexNum = HexNum + 2 ^ Abs(i - BinLen)
EndIf
Next i
BinToHex = Hex(HexNum)
ErrorHandler:
EndFunction
End
Module

disney_snoopy is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
binary and hexidecimal Shadowguardian Certification and Education 9 October 13th, 2008 11:19 AM
binary math ShuckyD IMO Community 8 February 3rd, 2007 08:15 PM
Simple Binary carl33p General Tech Discussion 4 September 8th, 2006 09:54 AM
Help on a binary wipe... v-a-m General Tech Discussion 3 August 28th, 2004 10:40 PM
Hexadecimal - Help me with the math please Bill in SD, CA General Tech Discussion 9 August 7th, 2003 01:16 PM

Most Active Discussions
Is It Just Me? (535)
Misery Loves Company... (1849)
Why Does the MOON Grow Bigger as It.. (18)
heatsink issue (10)
New Mobo (18)
UPGRADING C/D DRIVE TO 250GB & .. (14)
1 internet. 1 house. 3 computer. ho.. (13)
Is This A Compatible Gaming PC? (18)
SSD's, RAID, and External Backup (7)
Recent Discussions
webcam sharing (0)
help! jumbled text and computer.. (1)
Scanning problem (4)
DFI socket 939 board acting up (5)
Building my first PC and need s.. (2)
32 or 64 bit vista (4)
Big problem with my PC (2)
system restore 'next' button wo.. (2)
firewall (1)
FS: Dell 6000 laptop, modded 36.. (2)
Apple iPod touch 16 GB $200 (4)
Six 28-Disc Cross Design Black .. (4)


All times are GMT -4. The time now is 12:45 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28