Another VB question...

Mean MrMustard

Diamond Member
Jan 5, 2001
3,144
10
81
I need to load a listbox at Form Load time with information from a random access file.

Dim mess As Message
Dim pintRecNum As Integer

Open mstrAppPath & mstrFileName For Random As 1 Len = 200

pintRecNum = 0


mstrList = mess.lname & mess.date

Do While ...
Get 1, pintRecNum, mstrList
lstMessages.AddItem mstrList
pintRecNum = pintRecNum + 1
Loop

Close 1

I can't think of the DO WHILE condition, it needs to loop until the end of the file, but I can't get it to work. Any suggestions?
 

Mean MrMustard

Diamond Member
Jan 5, 2001
3,144
10
81
Thanks for replying, I figured it out about 5 minutes after I posted. I have another question though.

In the list box, the concatenated string needs to be aligned so that mess.lname is left-aligned and mess.date is right-aligned.

I know it goes something to this effect:

mstrTab = lstMessages.width - mess.lname - mess.date

So then the concatenated string would actually look like this: mstrList = mess.lname & mstrTab & mess.date

I can't get it to work
 

Lanik

Senior member
Oct 9, 1999
444
0
0
Alignment in a listbox would be a clientside thing and so your control would be limited. The only way to simulate this is by creating 's to make the alignment. I would suggest you make a function to simulate this.

For example:

strDone = RightAligned(strInput)

Function RightAligned(strInput)
Do While (Len(strInput) < 20)
strInput = "" strInput
Loop
RightAligned = strInput
End Function

So, the above function adds forced spaces to the front of the string until the string is 20 chars long.

Good luck.