Thanks, for this code. It was quite informative as I'm still learning this stuff. I have found the real problem with stuff lining up in the list box. It dosen't matter what font you setup up in the IDE it is ignored. I set the font to "Courier New" (which is fixed pitch) in the code and the stuff is now lining up on the PDA. I guess this is an IDE bug along with the others I reported.
George _____ From: [email protected] [mailto:[email protected]] On Behalf Of michiman56 Sent: Thursday, March 04, 2010 5:54 PM To: [email protected] Subject: [nsbasic-ce] Re: format help needed I don't know if this helps you in your case, but here is one idea for tabular data in a multiline Textbox. A multiline Textbox defaults to tabs every 8 positions. However with a simple API call you can set the tabs to other positions. Notes: * For some reason NSB/CE 8.1.2a here is not recognizing the supposedly "built in" SendMessage call, so I had to Declare one here. * The tabstop values are not in character-widths since most fonts are not monospaced. The values you must provide are roughly in "quarter of a character" units, so multiply the desired values in character positions by 4. * This works great with Courier New, but will also work with Tahoma since the position is not actually based on character widths but instead some screen metric that is fixed at about a "quarter character width." Sample code, one Form with one Textbox (named txtTable): ShowOKButton True 'Set Close button to OK Declare "Function SendMessage Lib ""CoreDLL""" _ & "Alias ""SendMessageW"" (ByVal hWnd As Long, " _ & "ByVal wMsg As Long, ByVal wParam As Long, " _ & "ByVal lParam() As Long) As Long" Const EM_SETTABSTOPS = &HCB Dim Count Sub Form1_Load Dim TabStops TabStops = Array(7 * 4, 15 * 4) SendMessage txtTable.Hwnd, EM_SETTABSTOPS, 2, TabStops txtTable.Text = _ "Count" & vbTab & "Random" & vbTab & "Random * 2" _ & vbNewLine Randomize txtTable.Timer = 500 End Sub Sub txtTable_Timer Dim Random Count = Count + 1 Random = Rnd() txtTable.Text = txtTable.Text _ & FmtNum(Count, 3, -1) & vbTab _ & FmtNum(Random, 6, 4) & vbTab _ & FmtNum(Random * 2, 8, 4) & vbNewLine If Count >= 10 Then txtTable.Timer = 0 End Sub Function FmtNum(ByVal Value, ByVal Width, ByVal Places) If Places < 0 Then Value = CStr(Value) 'Integer. Else Value = FormatNumber(Value, Places) 'Fractional. End If If Len(Value) > Width Then FmtNum = "*" & Right(Value, Width - 1) Else FmtNum = Right(Space(Width) & Value, Width) End If End Function The result displays nicely in 3 columns. --- In [email protected], "georgeewalters" <gwalt...@...> wrote: > > I'm trying to add items to a list box which all the fields will line up. > The text box font is Courier New which I think is fixed pitch. > > Here's the code that does not line up. > > '-- build list box text > tmp = Left(list(count,recBinNbr) & Space(5),5) > tmp = tmp & Left(UCase(list(count,recDesc1)) & Space(30),30) > tmp = tmp & Right(FormatNumber(list(count,recQtyDue),0,0,0,0),5) > ListBox1.AddItem tmp > > How can I fix this, or can you give me some sample code which does. > Thanks > -- You received this message because you are subscribed to the Google Groups "nsb-ce" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nsb-ce?hl=en.
