What's wrong with my structure ?

Falbala
10-26-2004, 03:14 AM
I want to fill a combobox with data from a recordset. Here is my code :
Private Type InfoJeu
idJeu As Integer
RefInterne As String * 15
nomJeu As String * 25
nomAire As String * 40
End Type
Private TabJeu() As InfoJeu
Private FormatinfoJeu As String * 80
.......................
TabJeu(I).idJeu = Rst!idJeux
TabJeu(I).nomJeu = Rst!nomJeux
TabJeu(I).RefInterne = Rst!RefInterne
TabJeu(I).nomAire = Rst!nomAire
FormatinfoJeu = TabJeu(I).RefInterne + TabJeu(I).nomJeu + TabJeu(I).nomAire

Combo1.AddItem (FormatinfoJeu)
This works but the result is varying depends on recordset. I mean i get this :
"VP001 John Smith"
"VP63287 Elisabeth Williams"
And i would like this :
"VP001 John Smith "
"VP63287 Elisabeth Williams"
How can i get a fixed structure (string15 + string25 + string40) whatever datas in it ?

Falbala
10-26-2004, 03:17 AM
Sorry this is not clear, here what i get
"VP001-John-Smith"
"VP63287-Elisabeth-Williams"
And i would like this :
"VP001----John------Smith---- "
"VP63287--Elisabeth--Williams--"

Flyguy
10-26-2004, 03:31 AM
Use the Format() while you are concattenating the strings.

Falbala
10-26-2004, 03:58 AM
...while you are concattenating the strings... Heu...could you explain me with a simple exemple ?

Falbala
10-26-2004, 05:02 AM
I tried this, but does not work.
FormatinfoJeu = Left$(Space$(1) & Rst!RefInterne, 15) +
Left$(Space$(1) & Rst!nomJeux, 25) +
Left$(Space$(1) & Rst!nomAire, 38)
Combo1.AddItem (FormatinfoJeu)
Any exemples of "Format" with several string ?

Flyguy
10-26-2004, 07:22 AM
The format a string a fixed amount of space use:

A = Format("Test", "!" & String(10, "@")) ' 10 characters, left aligned
A = Format("Test", String(10, "@")) ' 10 characters, right aligned

In your case do something like this:

FormatinfoJeu = Format(TabJeu(I).RefInterne, "!" & String(15, "@"))
FormatinfoJeu = FormatinfoJeu & Format(TabJeu(I).nomJeu, "!" String(25, "@"))
FormatinfoJeu = FormatinfoJeu & Format(TabJeu(I).nomAire, "!" String(40, "@"))

Falbala
10-26-2004, 07:52 AM
Many thanks Flyguy,
it didn't work first but once i changed the font it worked.
I changed "MS sans sherif" by "Courrier new".
Thanks again,

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum