+ Reply to Thread
Results 1 to 4 of 4

Help me please

  1. #1
    Registered User
    Join Date
    07-17-2006
    Posts
    3

    Help me please

    hey all,

    i had to write a program a while ago, actually in C, that is able to convert for example a dec in hex or any other number in binary, hex, oct....now i am having problems with writing the same in VBA. it would be great if somebody could post a code of a small VBA program that can convert any numbers.
    Heres the code of the C program, just to get you an idea of what i am talking about. Sorry for my bad english but i am from austria.

    thanks again, darcus

    #include <stdio.h>

    void main ()
    {
    /* Variable (Zeichen) definieren */
    unsigned char cZeichen;
    printf("\nBitte geben Sie ein beliebiges Zeichen ein: "); scanf("%c", &cZeichen);
    /* Anlegen einer Tabelle zur Umrechnung des eingegebenen Zeichens */
    printf("\n-----------------------------------------------------------------");
    printf("\n|\tASCII\t|\tDez.\t|\tHex.\t|\tOkt.\t|\n");
    printf("\-----------------------------------------------------------------\n");
    /* Berechnung des gesuchten Wertes für eingegebenes Zeichen */
    printf("\|\t%c\t|", cZeichen); /* Ausgabe des oben eingegebenen Zeichens in ASCII */
    printf("\t%d\t|", cZeichen); /* Ausgabe des eingegebenen Zeichens als Dezimalzahl */
    printf("\t%x\t|", cZeichen); /* Ausgabe des Zeichens als Hexadezimale */
    printf("\t%o\t|\n", cZeichen); /* Ausgabe des Zeichens als Oktalzahl */
    printf("\-----------------------------------------------------------------\n");

    }

  2. #2
    Peter T
    Guest

    Re: Help me please

    num = 123456789

    sHex = Hex(num)
    num2 = CLng("&H" & sHex)

    sOct = Oct(num)
    num3 = CLng("&0" & sOct)

    MsgBox sHex & vbCr & num2 & vbCr & vbCr & vbCr & sOct & vbCr & num3

    num4 = &HFFFFFF
    MsgBox num4, , "&HFFFFFF"

    num5 = &O123
    MsgBox num5, , "Oct:123"

    Regards,
    Peter T

    "darcus" <darcus.2b3jxs_1153151711.3136@excelforum-nospam.com> wrote in
    message news:darcus.2b3jxs_1153151711.3136@excelforum-nospam.com...
    >
    > hey all,
    >
    > i had to write a program a while ago, actually in C, that is able to
    > convert for example a dec in hex or any other number in binary, hex,
    > oct....now i am having problems with writing the same in VBA. it would
    > be great if somebody could post a code of a small VBA program that can
    > convert any numbers.
    > Heres the code of the C program, just to get you an idea of what i am
    > talking about. Sorry for my bad english but i am from austria.
    >
    > thanks again, darcus
    >
    > #include <stdio.h>
    >
    > void main ()
    > {
    > /* Variable (Zeichen) definieren */
    > unsigned char cZeichen;
    > printf("\nBitte geben Sie ein beliebiges Zeichen ein: "); scanf("%c",
    > &cZeichen);
    > /* Anlegen einer Tabelle zur Umrechnung des eingegebenen Zeichens */
    >

    printf("\n-----------------------------------------------------------------"
    );
    > printf("\n|\tASCII\t|\tDez.\t|\tHex.\t|\tOkt.\t|\n");
    >

    printf("\-----------------------------------------------------------------\n
    ");
    > /* Berechnung des gesuchten Wertes für eingegebenes Zeichen */
    > printf("\|\t%c\t|", cZeichen); /* Ausgabe des oben eingegebenen
    > Zeichens in ASCII */
    > printf("\t%d\t|", cZeichen); /* Ausgabe des eingegebenen Zeichens als
    > Dezimalzahl */
    > printf("\t%x\t|", cZeichen); /* Ausgabe des Zeichens als Hexadezimale
    > */
    > printf("\t%o\t|\n", cZeichen); /* Ausgabe des Zeichens als Oktalzahl
    > */
    >

    printf("\-----------------------------------------------------------------\n
    ");
    >
    > }
    >
    >
    > --
    > darcus
    > ------------------------------------------------------------------------
    > darcus's Profile:

    http://www.excelforum.com/member.php...o&userid=36449
    > View this thread: http://www.excelforum.com/showthread...hreadid=562113
    >




  3. #3
    Registered User
    Join Date
    07-17-2006
    Posts
    3
    thank you very very much! but another question, is there a possibility to convert the entered number in a binary number? i was trying to find any function or so but didnt come up with anything....thanks again!

    darcus

  4. #4
    Peter T
    Guest

    Re: Help me please

    > to convert the entered number in a binary number?

    Could you illustrate what you mean with an example of number entered and
    what that should convert to.

    Regards,
    Peter T


    "darcus" <darcus.2b405a_1153173417.4402@excelforum-nospam.com> wrote in
    message news:darcus.2b405a_1153173417.4402@excelforum-nospam.com...
    >
    > thank you very very much! but another question, is there a possibility
    > to convert the entered number in a binary number? i was trying to find
    > any function or so but didnt come up with anything....thanks again!
    >
    > darcus
    >
    >
    > --
    > darcus
    > ------------------------------------------------------------------------
    > darcus's Profile:

    http://www.excelforum.com/member.php...o&userid=36449
    > View this thread: http://www.excelforum.com/showthread...hreadid=562113
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1