4 Replies - 3007 Views - Last Post: 14 April 2010 - 04:44 PM Rate Topic: -----

#1 vkod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 31-March 10

pad a string with characters

Posted 13 April 2010 - 11:51 PM

Public Class Form1 
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
Dim just(4, 2) As Integer 
Dim row As Integer 
Dim col As Integer 
Dim vac As String() 
vac = New String(just.GetUpperBound(0)) {} 
 
ListBox1.Items.Clear() 
For row = 0 To 4 
For col = 0 To 2 

 
vac(row) = "Vacant" 
 
 
ListBox1.Items.Add(row & " " & col & " " & vac(row.ToString) & " ") 
 
Next 
 
Next 
 
 
 
End Sub 


plz how can I convert the column numbers(0, 1, 2 ...) in this program to letters (A, B, C ..). when a radiobutton is selected.
Any suggestion will be highly appreciated.
thanks

Plz I will like to pad some of the number in the column and row of the aboved loop. How will I go about doing it. thanks again

This post has been edited by vkod: 14 April 2010 - 03:49 PM


Is This A Good Question/Topic? 0
  • +

Replies To: pad a string with characters

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: pad a string with characters

Posted 14 April 2010 - 04:14 AM

hi there :)

use the ascii code of the letters
http://www.asciitable.com/

like so
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i As Int16 = 0 To 20
        'using 65 as ascii code of "A" and by using the sum with i we return the char represent of the new ascii code
            MessageBox.Show(Convert.ToChar(65 + i))
        Next
    End Sub



good luck :)
Was This Post Helpful? 0
  • +
  • -

#3 vkod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 31-March 10

Re: pad a string with characters

Posted 14 April 2010 - 04:21 AM

thanks. I got it.
Was This Post Helpful? 0
  • +
  • -

#4 vkod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 31-March 10

Re: pad a string with characters

Posted 14 April 2010 - 03:51 PM


Plz I will like to pad some of the number in the column and row of this program. How will I go about doing it. thanks again

Was This Post Helpful? 0
  • +
  • -

#5 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: pad a string with characters

Posted 14 April 2010 - 04:44 PM

Check out .PadLeft and .PadRight of the string class

Textbox1.Text = Textbox1.Text.PadLeft(6,CChar"0")

5 will result in 000005
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1