10 Replies - 5435 Views - Last Post: 02 October 2011 - 06:14 PM Rate Topic: -----

#1 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 12:53 PM

Hello all, My project is to write a program that displays in a textBox a table of binary, octal and hexadecimal equivalents of the decimal numbers in the range of 1-255. Everything works well except the numbers need to be aligned under the headers. First letter and I would like to see in the binary group the binary's look more elegant if possible.?

Here is my code
'This program should display a texBox with binary, octal hexadecimal and decimal equivalents



Public Class DecimalEquivalents


    Private Sub txtBoxOutPut_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim sTemp As String = ""

        'strings Header
        sTemp = "Decimal" & vbTab & vbTab & "Octal" & vbTab & vbTab & "Hexadecimal" & vbTab & "Binary" & vbCrLf
        sTemp = String.Format("{0, 10} {1, 10} {2, 15} {3, 10}", "Decimal", "Octal", "Hexadecimal", "Binary")

        'strings equivalents
        For i As Integer = 1 To 255
            sTemp = sTemp & String.Format("{0,10} {0, 10:X} {1, 15:C} {2, 10:C}", i, Convert.ToString(i, 8), Convert.ToString(i, 2)) & vbCrLf


        Next
        txtBoxOutPut.Text = sTemp
    End Sub

End Class



Also JimBo if you're out there I have some drawings for you to look at and would like to e-mail or figure out how to get them to you for your logo. Have to scan them in at school tomorrow before I can get them to you.

Is This A Good Question/Topic? 0
  • +

Replies To: Decimal, Octal, Hexadecimal and Binary - set up problem

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8371
  • View blog
  • Posts: 31,099
  • Joined: 12-June 08

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 01:17 PM

Do you have a screen shot of how this looks now?
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1029
  • View blog
  • Posts: 4,008
  • Joined: 02-July 08

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 02:03 PM

You can add .PadRight or .PadLeft to each of the string variables you have in the String.Format to get them to align better. That with a fixed width font - like Consolas or Courier, etc..., you can achieve the results you want.

This post has been edited by _HAWK_: 02 October 2011 - 02:04 PM

Was This Post Helpful? 1
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 02:08 PM

If i remember correct you can use -20 to change it to right/left side
Was This Post Helpful? 1
  • +
  • -

#5 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 03:06 PM

View Postmodi123_1, on 02 October 2011 - 01:17 PM, said:

Do you have a screen shot of how this looks now?



I tried to do a screen shot here's a pdf with the screen shot on it. Not quite sure how to do a screen shot and post it to this box I'm not sure how to post a screen shot, won't let me upload a word doc and the pdf's not uploading???? Do I take it into photoshop and turn it into a jpg?

Attached File(s)


This post has been edited by charyl: 02 October 2011 - 03:28 PM

Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 03:30 PM

Just let me apologise if any of my prior post was visible, I posted it in the wrong Chrome tab.
: embarrassed:

This post has been edited by AdamSpeight2008: 02 October 2011 - 03:51 PM

Was This Post Helpful? 0
  • +
  • -

#7 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 03:45 PM

okay it's just my 1's at the beginning that are not aligned. On the binary code all the 1's should align to the left. It's not bad, it's just not perfect. Somehow my pdf's are now not saving to my computer.
Was This Post Helpful? 0
  • +
  • -

#8 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 03:53 PM

I just noticed that the decimal line only goes to 77 and then jumps to 100? Think I have the alignment problem solved for a minute, although binary could look better. Here's my code do you see why my decimals are only going to 77 and then jumping to 100?

'This program should display a texBox with binary, octal hexadecimal and decimal equivalents

Public Class DecimalEquivalents


    Private Sub txtBoxOutPut_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim sTemp As String = ""

        'strings Header
        sTemp = "Decimal" & vbTab & vbTab & "Octal" & vbTab & vbTab & "Hexadecimal" & vbTab & "Binary" & vbCrLf
        sTemp = String.Format("{0, 10} {1, 10} {2, 15} {3, 10}", "Decimal", "Octal", "Hexadecimal", "Binary") & vbCrLf

        'strings equivalents
        For i As Integer = 1 To 255
            sTemp = sTemp & String.Format("{1,4} {0, 15:X} {1, 10:C} {2, 23:C}", i, Convert.ToString(i, 8), Convert.ToString(i, 2)) & vbCrLf


        Next
        txtBoxOutPut.Text = sTemp
    End Sub

End Class


nevermind, figured that one out. Now just the binary alignment if anyone has any suggestions, not sure how .padleft looks in code or if this is the solution. Not sure how to code that?
Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 03:56 PM

Have a look through the FormatProviders

This post has been edited by AdamSpeight2008: 02 October 2011 - 03:56 PM

Was This Post Helpful? 1
  • +
  • -

#10 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 06:00 PM

I read your link, it was a little confusing. Seems like there should be something simple. I see where and what is happening. Every time there is a 2nd or 3rd number entered it all moves over 1. For instance 10, 100, 1000 do you know of an if...then or something simple like that. Seems like the codes that I viewed had a lotof extra code, makes it seem wordy or complicated?
Was This Post Helpful? 0
  • +
  • -

#11 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: Decimal, Octal, Hexadecimal and Binary - set up problem

Posted 02 October 2011 - 06:14 PM

But I am excited to have that link and it will come in handy for other projects!!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1