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

Need a control like a textbox which holds more data 1

Status
Not open for further replies.

CaKiwi

Programmer
Apr 8, 2001
1,294
US
I want to load a file into a window and allow the user to do simple editing on it. A text box would be ideal for this except that it will not hold enough data. Is there another control which I could use to acomplish this?

Thanks in advance. CaKiwi
 
Is that quite a big text file?

I quote from VBHelp:
Text entered into the TextBox control is contained in the Text property. You can enter up to 2,048 characters in a text box. If you set the MultiLine property of the control to True, you can enter up to 32 KB of text
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
johnwm, although I'd rather not nit-pick, I'm going to here. Typically, I've found the limits to be true, unless running on Win2000/XP (haven't tried NT). Then, it seems, the textbox is limitless?

*shrug* -iNSTA
aim: instar4per
email: instar4per @ hotmail.com
 
instar4per

Thanks for your comment. I must admit I haven't personally used a textbox for long strings. As I said originally 'I quote from VBHelp' Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
vb5prgrmr - Thanks for the suggestion, I will try a richtextbox and post the results. Failing that, I will shell notepad, passing the filename. At present I am using a listbox to display the data.

johnwm - The file will usually be 50-100kb but could be up to 1mb. I saw that the documented maximum for a textbox was 32kb but I have loaded more than 40kb into one. CaKiwi
 
The textboxes can accept large amounts of text ok (64K for a multiline textbox in W95/98/Me, and - theoretically - 4Gb under NT/2000/XP; in both cases the size is less, 32K and 2Gb respectively, for a single line textbox). The problem is that VB doesn't know how to access it properly, as it has some artificial restraints. Try the following (this example is for NT/2000/XP, since the numbers I use exceed the 64K W95/98/Me limit.). You just need a form with a textbox (I suggest set to single line as it's faster...) and a command button:
[tt]
Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC



Private Sub Command1_Click()


' The VB way
fred = String(128000, "a")
Text1.Text = fred
MsgBox "VB can see " & Len(Text1.Text) & " bytes"

' The API way
SendMessage Text1.hwnd, WM_SETTEXT, 0&, ByVal fred

MsgBox "VB can now see " & Len(Text1.Text) & " bytes"
' But, for example, you can't set SelStart to any larger than 65535

End Sub
 
strongm - Thanks for your suggestion, I will try it and post the results. I am developing on windows 98 so the data from the file will exceed the 64kb limit there but the final application will run on windows NT. CaKiwi
 
CaKiwi, If you decide to go the notepad route, notepad only accepts up to about 10k if I'm not mistaken.

 
dragnut - Right, I'll use wordpad if all else fails. CaKiwi
 
vb5prgrmr - The RichTextBox worked fine. I loaded a 1.5mb file into it without any problems. Thanks for your suggestion. CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top