Question Text Box Formatting Question

smith4595

New member
Joined
Jan 24, 2013
Messages
3
Programming Experience
Beginner
I'm relatively new to programming in VB.Net. I've dabbled in it before, but I'm trying to be more proactive at work and create some applications to make some of my work easier (and also help out our end-users).

I've created a tool that will pull information about a computer such as username, computer name, serial, etc. The tool places this information into a multi-line text box. What I'm trying to figure out how to do is display the text as follows so it fills the entire width of the text box.

User Name..........................XXXXXXX
Computer Name...................XXXXXXX
Serial Number......................XXXXXXX
Etc

Where the the text will be autoformated to right justification with the appropriate number of "....." Hopefully this makes sense.

To recap, I want the text box display info like this "User Name" & APPROPRIATE NUMBER OF ...... & (Right Justification "XXXXXXXX") & vbclrf _ next line...

The problem maybe I just don't know how to explain what I'm trying to accomplish. Any help would be much appreciated.
 
Any chance you could provide an example?

After thinking about it some more..why not just do something like this:

VB.NET:
txtLog.AppendText("User Name" & ".........................." & "XXXXXXX" & vbCrLf)
txtLog.AppendText("Computer Name" & "..................." & "XXXXXXX" & vbCrLf)
txtLog.AppendText("Serial Number" & "......................" & "XXXXXXX" & vbCrLf)
 
Been messing around with some options and come up with the following:

TextBox9.Text = "User Name" & "".PadLeft(30, CChar(".")) & strusername & vbCrLf & _
"Computer Name" & "".PadLeft(30, CChar(".")) & strmachinename & vbCrLf & _
"Serial Number" & "".PadLeft(30, CChar(".")) & SystemSerialNumber() & vbCrLf & _
"IP Address" & "".PadLeft(30, CChar(".")) & strip & vbCrLf & _
"Manufacturer" & "".PadLeft(30, CChar(".")) & strmake & vbCrLf & _
"Model" & "".PadLeft(30, CChar(".")) & strmodel & vbCrLf & _
"OS Version" & "".PadLeft(30, CChar(".")) & stros & vbCrLf & _
"Domain" & "".PadLeft(30, CChar(".")) & strdomain

however it's not lining up properly as I want it.
 
You are padding an empty string, shouldn't you pad an existing string?
 
Textbox.Text = mystring.PadLeft(30, " "c)

will work, but you need to use a non-proportional font (such as Courier New) that keeps the same size for each character.

I would also suggest using a listbox for each item, rather than a textbox. That would be a lot neater than using all the concatenation and newline code. Just add another instruction for each data item:

Listbox.Items.Add(mystring.PadLeft(30, " "c)
 

Latest posts

Back
Top