# Decimal, Octal, Hexadecimal and Binary - set up problem

Page 1 of 1

## 10 Replies - 11838 Views - Last Post: 02 October 2011 - 06:14 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=249513&amp;s=979eec25d6febbcbf88092502262b24d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 charyl

• D.I.C Regular

Reputation: 4
• 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 = ""

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

• Suitor #2

Reputation: 13947
• Posts: 55,683
• 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?

### #3 _HAWK_

• Master(Of Foo)

Reputation: 1162
• Posts: 4,444
• 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

• MrCupOfT

Reputation: 2298
• Posts: 9,535
• 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

### #5 charyl

• D.I.C Regular

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

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

Posted 02 October 2011 - 03:06 PM

modi123_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

• MrCupOfT

Reputation: 2298
• Posts: 9,535
• 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

### #7 charyl

• D.I.C Regular

Reputation: 4
• 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.

### #8 charyl

• D.I.C Regular

Reputation: 4
• 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 = ""

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?

• MrCupOfT

Reputation: 2298
• Posts: 9,535
• 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

### #10 charyl

• D.I.C Regular

Reputation: 4
• 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?

### #11 charyl

• D.I.C Regular

Reputation: 4
• 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!!!!