Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 107,639 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 957 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



binary to hexadecimal

 
Reply to this topicStart new topic

binary to hexadecimal

disney_snoopy
post 1 Jul, 2008 - 02:18 AM
Post #1


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 2

Hi all,

Can anyone help me to do a visual basic.net programming that is convert binary to hexadecimal?
Besides, this program also need to include the For-loop and the Select Case statement.

Thank you.
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 1 Jul, 2008 - 02:18 AM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,833



Thanked 27 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.

You might want to check the code snippets & tutorials sections, someone may have posted something similar that can get you started.
User is online!Profile CardPM

Go to the top of the page

jacobjordan
post 1 Jul, 2008 - 01:54 PM
Post #3


class Me : Perfection

Group Icon
Joined: 11 Jun, 2008
Posts: 619



Thanked 14 times

Dream Kudos: 1350
My Contributions


I don't know how to convert a binary number to hex, but i do know how to convert a base-10 number to hex with this function

vb

Conversion.Hex(Number As Object) As String

Hope that can be of some use.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 1 Jul, 2008 - 02:02 PM
Post #4


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,141



Thanked 50 times

Dream Kudos: 7700

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


Moved to VB.NET
User is online!Profile CardPM

Go to the top of the page

disney_snoopy
post 1 Jul, 2008 - 04:54 PM
Post #5


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 2

Hi all,

Can anyone help me to check where i did wrong for my visual basic.net programming that is convert binary to hexadecimal?

Thank you.

CODE
Imports System.Math
Module Module1

    Sub Main()
        Dim s As String
        Console.Write("Please enter a binary: ")
        s = Console.ReadLine()
        Console.ReadLine()
    End Sub

    Function BinToHex(ByVal BinNum As String) As String
        Dim BinLen As Integer
        Dim HexNum As Object
        BinLen = Len(BinNum)
        If BinNum.Length > 0 Then
            Select Case (BinNum.Length)
                Case 1
                    If BinNum.Length > 8 Then
                        Console.WriteLine("The Hex number is: ", BinNum.Length)
                    Else
                        Console.WriteLine("Hex number is: ", HexNum.Length)
                    End If
            End Select
        End If
        BinToHex = Hex(HexNum)
    End Function

End Module
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 1 Jul, 2008 - 05:13 PM
Post #6


D.I.C Regular

Group Icon
Joined: 29 May, 2008
Posts: 493



Thanked 31 times

Dream Kudos: 1900
My Contributions


QUOTE(disney_snoopy @ 2 Jul, 2008 - 12:54 AM) *

Hi all,

Can anyone help me to check where i did wrong for my visual basic.net programming that is convert binary to hexadecimal?

Thank you.

CODE
Imports System.Math
Module Module1

    Sub Main()
        Dim s As String
        Console.Write("Please enter a binary: ")
        s = Console.ReadLine()
' --> Insert call to function BinToHex
' --> Display result of that call
    Console.ReadLine()
    End Sub

    Function BinToHex(ByVal BinNum As String) As String
        Dim BinLen As Integer
        Dim HexNum As Object
        BinLen = Len(BinNum)
        If BinNum.Length > =1 and  Then
            Select Case (BinNum.Length)
                Case 1
                    If BinNum.Length > 8 Then
                        Console.WriteLine("The Hex number is: ", BinNum.Length)
                    Else
                        Console.WriteLine("Hex number is: ", HexNum.Length)
                    End If
            End Select

        End If
      BinToHex = Hex(HexNum) '<- Are you using the right variable?
' Shouldn't this be with then If statement?
    End Function

End Module


User is offlineProfile CardPM

Go to the top of the page

Locke37
post 1 Jul, 2008 - 07:30 PM
Post #7


D.I.C Regular

Group Icon
Joined: 20 Mar, 2008
Posts: 366



Thanked 12 times

Dream Kudos: 250
My Contributions


And 2nd of all, don't make a duplicate thread in the wrong forum (again). There is a VB.NET forum here...
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 1 Jul, 2008 - 10:48 PM
Post #8


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,716



Thanked 20 times

Dream Kudos: 2800

Expert In: C, C++, VB, VB.NET, C#, Java, x86 Assembly, Win32 API, Reversing

My Contributions


Moved.
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 1 Jul, 2008 - 11:00 PM
Post #9


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,716



Thanked 20 times

Dream Kudos: 2800

Expert In: C, C++, VB, VB.NET, C#, Java, x86 Assembly, Win32 API, Reversing

My Contributions


Topics Merged.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/29/08 07:06PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month