Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spaces in a listbox

Status
Not open for further replies.

wvjim

Programmer
Jan 11, 2001
25
0
0
US
I'm trying to fill a list box in a columnar format. I move my data to a single string field (to eventually move into the list box) and all of the spaces are there but when I move the string to the listbox they are removed.

ie. I want to dipslay "CLK Clerk 20.00 P"

and what I actually get is "CLKClerk20.00P"

I saw a response from someone else sometime back that said
"change the font to a mono space font. That way all the characters will be the same width and you can use traditional string formatting to do what you want.

I think "Lucida Console" is a mono space font."

That does not seem to correct the problem.

Thanks in advance
 
Thanks very much for your response, riverguy. I had already tried courier and that didn't work either. Any other ideas? I'm sorta floundering.

Jim
 
Can you post the code you are using to move the string?

- B
 
Here's a snippet that'll show how I'm getting this move done:

strDetail = " "
strDetail = Mid(strDetail, 1, 3) & (rdrD("reccod"))
strDetail = Mid(strDetail, 1, 6) & " "
strDetail = Mid(strDetail, 1, 9) & "This is The Description"
strDetail = Mid(strDetail, 1, 49) & " "
strDetail = Mid(strDetail, 1, 41) & (rdrD("recamt"))

lbDetails.Items.Add(strDetail)
When I run this the field strDetail looks fine, but when I display it on the form in lbDetails it removes all but one space between the fields.
 

Try:

[tt]
strDetail = " "
strDetail = strDetail & Mid(strDetail, 1, 3) & (rdrD("reccod"))
strDetail = strDetail & Mid(strDetail, 1, 6) & " "
strDetail = strDetail & Mid(strDetail, 1, 9) & "This is The Description"
strDetail = strDetail & Mid(strDetail, 1, 49) & " "
strDetail = Mid(strDetail, 1, 41) & (rdrD("recamt"))

lbDetails.Items.Add(strDetail)

[/tt]

- B
 
Actually, this is what you want:
[tt]
strDetail = " "
strDetail = strDetail & rdrD("reccod"))
strDetail = strDetail & " "
strDetail = strDetail & "This is The Description"
strDetail = strDetail & " "
strDetail = strDetail & (rdrD("recamt"))

lbDetails.Items.Add(strDetail)
[/tt]

- B
 
Well, that still left me with the problem of the list box condensing all but one of the blanks out of the string. The following code actually was what was needed. I thought I'd post it just in case you were interested. The '&nbsp' combined with the htmldecode instruction actuall cause the blanks to display.

lbDetails.Items.Clear()

' Set up fields to be displayed on the screen
While rdrD.Read

' First get the length of the description and find out how many spaces must be appended to the
' end
x = Len(Trim(rdrD("fddesc")))
x = 30 - x
i = 0
strSp = " "

If x <> 0 Then
For i = 1 To x
strSp = strSp & &quot;&nbsp;&quot;
Next
End If

strAmt = Format((rdrD(&quot;recamt&quot;)), &quot;#,###.00&quot;)
x = strAmt.Length
x = 14 - x
i = 0
strAmtSp = &quot;&nbsp;&quot;
If x <> 0 Then
For i = 1 To x
strAmtSp = strAmtSp & &quot;&nbsp;&quot;
Next
End If

strDetail = &quot;&nbsp;&nbsp;&nbsp;&quot; _
& (rdrD(&quot;reccod&quot;)) _
& &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot; _
& (rdrD(&quot;fddesc&quot;)) _
& strSp _
& strAmtSp & strAmt _
& &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot; _
& (rdrD(&quot;recflg&quot;))
lbDetails.Items.Add(Server.HtmlDecode(strDetail))

Sorry about the length, but I wanted a complete example.

Jim
End While
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top