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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

results are NOT aligned in a LISTBOX !

Status
Not open for further replies.

y3by

Programmer
Joined
Jan 15, 2002
Messages
92
Location
PT
hi ppl,

in my vb code i have a listbox lst1
in whitch i add some items....
but in the lstbox they dont appear aligned

next the code and the exemple:

codpergunta is the name of the field in the bd that i opened before this code...

cod = CStr(rec.Fields("codpergunta"))
If Len(cod) < 10 Then
For i = Len(cod) + 1 To 10
cod = cod & &quot; &quot;
Next
End If
codf = cod

pergunta= rec.Fields(&quot;pergunta&quot;))
If Len(pergunta) < 60 Then
For i = Len(pergunta) + 1 To 60
pergunta = pergunta & &quot; &quot;
Next
End If
perguntaf = pergunta

resposta = rec.Fields(&quot;resposta&quot;)) ' only one char
respostaf = &quot; &quot; & resposta & &quot; &quot;

linha=codf & perguntaf & respostaf
lst1.additem linha


and when i run this with the previews exemple i obtain this:


cod Pergunta Resposta

1321 xxdxxxttttauyuuauuusisisisiic A
11 jjajksks sdddsdbnsbdsjbsjsdfsdkjfdsk B
2245564 kkfkkfklffdgfgçdlkfçgd C




but the wanted result was:




cod Pergunta Resposta

1321 xxdxxxttttauyuuauuusisisisiic A
11 jjajksks sdddsdbnsbdsjbsjsdfsdkjfdsk B
2245564 kkfkkfklffdgfgçdlkfçgd C


how can i obtain the correct result!??!?!
thanks
 
Hi,
Instead of using a loop to add spaces to the string try the Space() statement.
e.g.
codf = cod & Space(10 - Len(cod))

Jon
 
Or.. Try setting the listbox to use a fixed-pitch font like Courier.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top