--------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: E1F00000 Date: 01/10/97 From: KURT J. TISCHER Time: 10:32am \/To: DIK COATES (Read 4 times) Subj: Time/Date Stamp DC>Comes from using other programming languages... VB is my latest... and I DC>find DC>it great... except... Used to be that better than half my programming eff DC>went into the user interface... not now! Isn't it great!? I also made a very easy change to the event based nature of the VB environment. I mean, top-down, structured programming is fine and we still must think that way at times, even within VB, however, I was yearning for a development tool that worked under the notion that "anything can happen, at virtually any time, in any order" and VB was the ticket. BTW... I found something else that will work much more efficiently than the QB snippet you sent. It comes from the VB Knowledge Base and the topic title is "How to Print a Multi-Line Text Box in VB Using the SendMessage API". The example given is used to print the contents of the textbox to the printer, but it can be modified with minimal effort to print or write to a file, so..... Still, I appreciate the digging you did for me and I'll send up that code to you in order to save you any time should you need to do the same sometime. Kurt * SLMR 2.1a * My reality check just bounced. --- SLMAIL v4.5a (#4334) * Origin: 3RD EAR BBS - Middleburg Hts., OH (216) 234-6088 (1:157/438) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: E1F00001 Date: 01/10/97 From: KURT J. TISCHER Time: 10:38am \/To: GARY SONNENBERG (Read 4 times) Subj: Data Controls in VB 3.0 GS> KJT> I want the caption of the data control to read: GS> KJT> "Record (n) of (Number of Records)" GS> You can get Number of Records with RecordCount. I think you might be abl GS> to dynamically place this in the Data Control's caption by assigning it GS> a variable. But I'm not sure if the 'n' is doable since you're working GS> with a relational database. Do you have records sorted? Always the same GS> way? Otherwise maybe there's not much point in doing this?? GS> Perhaps there's a way by keeping track of MoveNext and MovePrevious call I knew about getting the number of records with RecordCount, however, I can't seem to find any Method or Property that will help me grab the number of the current record. Oh shit!!!! Wait a minute!!!!! I have the source code to the Data Manager! I DL it from the MS Download service! If the data manager can do it, so can I. hehe Cya! * SLMR 2.1a * All hope abandon, ye who enter messages here. --- SLMAIL v4.5a (#4334) * Origin: 3RD EAR BBS - Middleburg Hts., OH (216) 234-6088 (1:157/438) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: E1F00002 Date: 01/10/97 From: KURT J. TISCHER Time: 11:34am \/To: FRANK JAACKS (Read 4 times) Subj: Line-Break in VB-Textbox FJ>Hi there, FJ>how can i set a Line-Break in Textboxes ? FJ>I want set eg. an Line-Break (Line-Wrap) at Col 80 so i can save the Text FJ>for FJ>User in DOS-Mode that can't show Lines geater than 80 Colums. FJ>The Break must in the Textbox because the Textformat must be right. See my post to DIK COATES about the LF in Text Box regarding the Windows SendMessage API. * SLMR 2.1a * Back Up My Hard Drive? I Can't Find The Reverse Switch! --- SLMAIL v4.5a (#4334) * Origin: 3RD EAR BBS - Middleburg Hts., OH (216) 234-6088 (1:157/438) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: E1F00003 Date: 01/10/97 From: KURT J. TISCHER Time: 11:44am \/To: DIK COATES (Read 4 times) Subj: LF in Text Box Hi Dik... Here's the API for doing the text box thing we've been conversing about... If you are using VB 4.0, I am not sure if this particular API will work, but at least you can give it a shot... How to Print Multiline Text Box Using Windows API Functions Article ID: Q80867 --------------------------------------------------------------------- The information in this article applies to: - Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0 --------------------------------------------------------------------- SUMMARY ======= Printing the Text property of a multiline text box while maintaining the line structure requires attention to word wrapping, carriage returns, and line feeds. The programmer can either track the number of characters and lines in code or use Windows API functions to manipulate the Text property. This article demonstrates these techniques in a Visual Basic example. MORE INFORMATION ================ The example below demonstrates how to use the API function SendMessage() to track the number of lines in a multiline text box and to select and print the lines the way they appear, with line breaks or word wrapping intact. This code will work without modification even if the form and controls are resized at run time. The actual position of word wrapping will change. For more information about API functions relating to text boxes, query on the following words in the Microsoft Knowledge Base: ("API") and ("text") and ("box") and ("manipulate") Step-by-Step Example -------------------- 1. Create a form (Form1) and place a label (Label1), text box (Text1), and command button (Command1) on it. 2. Set the following properties at design time: Control Property Setting -------------------------------------------------------- Text box TabIndex 0 (zero, or first in tab order) Text box MultiLine True Label AutoSize True Label Name aGetLineCount 3. Add the following code to the (general) (declarations) section of the form: NOTE: If you copy-and-paste the code directly from here to Visual Basic, try to make sure that before you paste, you remove all carriage returns from code strings that must appear on one line. ' Enter the following Declare statement on one, single line: Declare Function SendMessage% Lib "user" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam As Any) Dim Buffer As String Dim resizing As Integer Const EM_GETLINE = &H400 + 20 Const EM_GETLINECOUNT = &H400 + 10 Const MAX_CHAR_PER_LINE = 80 ' Scale this to size of text box. 4. Add the following code to the Form_Load procedure: Sub Form_Load () ' Size form relative to screen dimensions. ' Could define all in move command but recursive definition causes ' extra paints. form1.width = screen.width * .8 form1.height = screen.height * .6 ' Enter the following form1.Move method on one, single line: form1.Move screen.width\2-form1.width\2, screen.height\2-form1.height\2 End Sub 5. Add the following code to the Form_Resize procedure: Sub Form_Resize () resizing = -1 ' Global flag for fGetLineCount function call. ' Dynamically scale and position the controls in the form. ' This code also is executed on first show of form. Text1.Move 0, 0, form1.width, form1.height \ 2 Text1.SelStart = Text1.SelStart ' To avoid UAE, see Q80669. ' Enter the following two lines as one, single line: command1.Move form1.width\2-command1.width\2, form1.height-form1.height\4 ' Enter the following two lines as one, single line: aGetLineCount.Move form1.width \ 2 - command1.width \ 2, Text1.height X% = fGetLineCount() ' Update to reflect change in text-box size. resizing = 0 End Sub 6. Add the following code to the Command1_Click event: Sub Command1_Click () '* Pop up an inputbox$ to allow user to specify which line '* in the text box to print or print all lines. '* Also check bounds so that a valid line number is printed. OK = 0 ' Zero the Do Loop flag. NL$ = Chr$(13) + Chr$(10) prompt$ = "Which line would you like to print?" prompt1$ = prompt$ + NL$ + "Enter -1 for all" prompt2$ = "Too many lines" + NL$ + "Try again!" + NL$ + prompt1$ prompt$ = prompt1$ Do response$ = InputBox$(prompt$, "Printing", "-1") If response$ = "" Then Exit Sub ' If user hits cancel, then ' exit. If Val(response$) > fGetLineCount&() Then prompt$ = prompt2$ Else OK = -1 ' Line chosen is in valid range, so exit DO. End If Loop Until OK If Val(response$) = -1 Then ' Print all lines... ndx& = fGetLineCount&() For N& = 1 To ndx& Buffer = fGetLine(N& - 1) printer.Print Buffer ' ...or print to the screen. Next N& Else ' Print a line... Buffer = fGetLine(Val(response$) - 1) printer.Print Buffer ' ...or print to the screen. End If printer.enddoc End Sub 7. Add the following code to the (general) (declarations) section of the form's code: Function fGetLine$ (LineNumber As Long) ' This function fills the buffer with a line of text ' specified by LineNumber from the text-box control. ' The first line starts at zero. byteLo% = MAX_CHAR_PER_LINE And (255) '[changed 5/15/92] byteHi% = Int(MAX_CHAR_PER_LINE / 256) '[changed 5/15/92] Buffer$ = chr$(byteLo%) + chr$(byteHi%)+Space$(MAX_CHAR_PER_LINE-2) ' [Above line changed 5/15/92 to correct problem.] x% = SendMessage(text1.hwnd, EM_GETLINE, LineNumber, Buffer$) fGetLine$ = Left$(Buffer$,X%) End Function Function fGetLineCount& () ' This function will return the number of lines ' currently in the text-box control. ' Setfocus method illegal while in resize event, ' so use global flag to see if called from there ' (or use setfocus before this function call in general case). lcount% = SendMessage(text1.hwnd, EM_GETLINECOUNT, 0&, 0&) aGetLineCount.caption = "GetLineCount = " + Str$(lcount%) fGetLineCount& = lcount% End Function 8. Add the following code to the Text1_Change event: Sub Text1_Change () X% = fGetLineCount() '* Update label to reflect current line End Sub 9. Save the project. Then run the application (press F5). 10.Type text in the text box, and either let it wrap or use the ENTER key to arrange lines. 11.Choose the Command1 button or TAB and press ENTER. 12.Choose the default (which prints all lines) or enter the line you want. Choose OK. If you choose Cancel, nothing will print. 13.Resize the form and repeat steps 10 through 12 above. The text will appear on the printed page as you see it in the text box when you press the Command1 button. NOTE: This example can be modified to send the contents of the text box to a file or a form instead of to the printer object. REFERENCES ========== Please see the "Microsoft Windows Programmer's Reference Book and Online Resource" (Visual Basic Add-on Kit #1-55615-413-5). Additional reference words: 2.00 3.00 textbox KBCategory: kbprg kbcode KBSubcategory: PrgCtrlsStd APrgWindow Hope you find this as useful as I did! Kurt --- SLMAIL v4.5a (#4334) * Origin: 3RD EAR BBS - Middleburg Hts., OH (216) 234-6088 (1:157/438) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: E1F00004 Date: 01/10/97 From: FRANCOIS ROY Time: 07:56am \/To: DIK COATES (Read 4 times) Subj: Re: Events DC> for creating user interfaces... for sure... try doing some serious DC> arithmetic with it and you'll change your mind... going to have to DC> ' DC> ' RET: sff(dof%,4) beam stiffness matrix DC> ' DC> SUB BeamStiffness (nmbint%, Ecb, iz(), l(), jrl%(), id%(), dof%, sff()) DC> DC> REDIM sff(dof%, 4), sm#(4, 4), im%(4) You might want to think about explicitly declaring 'sff' as a Single (either by appending the "!" or in the REDIM), because, in VB, the default data type is Variant (which is synonymous with "slow as h*ll") and not Single. The same applies to other variables (like 'l()' , 'iz()' and 'Ecb'). --- ME2_1104 * Origin: Out of String Space - the Final Frontier (Fidonet 1:163/215.23) --------------- FIDO MESSAGE AREA==> TOPIC: 178 VISUAL BASIC Ref: E1F00005 Date: 01/09/97 From: CHRIS ROACH Time: 04:57am \/To: BUCKY CARR (Read 4 times) Subj: API Bucky, I hope I didn't give you the wrong idea about apis..like DOS you just call em...they're there already...it's just the knowing 'how' part that means getting books. Much like dos int it's nice to know what needs to be where before you call a routine. Application Programming Interface (API) is just the methods/structure for a library ..esp kernel32. This stuff shows us progers which parms to put where--before calling a function in the api. It's like a function cookbook of sorts. If you have the libraries, you have the functions, but one needs docs galore to use all that functionality. Check out Declare statements in your module files (samples) to see how api calls are written and used. You have to have the correct bit o code for each function you wish to use. Heres a sample: Private Declare Function GetSysColor Lib "user32.dll" _ (ByVal nIndex as Integer) as Long Then you could do this: me.backcolor = GetSyscolor(0) System colors run from 0 to about 20 or 25. Each index is a certain parm, like screen backcolor or button hilite etc. Without docs you guess at these things. Many apis can be fiddled with, without docs, given the proper declare. I occassionally mess with them anyway, to look for hidden functionality that might not be documented. Best to stay 'inbounds' though-via API documentation. Hope this helps.. --- PCBoard 15.2 * Origin: 32 lines 40 Gig BBS, Realtime InterNet SLIP (403)247-7900 (1:134/10)