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?
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?
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
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.