Entering Large Amounts of Text

Entering Large Amounts of Text

I have a problem with writing text in Visual Basic. I would like to enter several hundred pages of text into my program, Any ideas of how to do this easily? The Label Box and Text box allow very little and will not work to my knowledge. And I don’t want to have type Print “” every time I write a line. If you have any ideas I would appreciate it if you would reply!

You might want to look at one of the VBXs that allows larger amounts of text than just 64k (or 32k in the case of VB3.0). You may also want to look at changing your program so that it automatically saves the text whenever you get a certain amount of text into the box. Once the limit is reached, the program saves the text, clears the box, and you continue typing.The problem here is that it will soon become a real bear trying to keep track of the saved text. One suggestion would be to save them in separate, serially numbered files (e.g. myproj01.txt, myproj02.txt, etc.) and keep track of each of them in an array so that you can “page” forward and back between the files. To ease the transition time between “pages” you can read in an entire textfile “in a gulp” like this:

Dim FileHnd As Long       ‘this sets up a variable for the file handle (for the Open statement)Dim FileBuffer As String   ‘this will be used as a buffer to receive the contents of the text fileFileHnd = FreeFile           ‘assign a file handle number to our variable’this next line puts together a string of spaces into the FileBuffer variable’note that I hardcoded the “C:setuplog.txt” for my test because it was about 60k and’already on my harddrive.  Use any filename you want (including a passed variable with the’pathfilename in it)FileBuffer = String(FileLen(“C:setuplog.txt”), ” “)Open “C:setuplog.txt” For Binary As FileHnd   ‘open the file for binaryGet #FileHnd, , FileBuffer                                  ‘read the whole thing into the bufferText1.Text = FileBuffer                                      ‘assign the buffer’s contents to your textboxClose #FileHnd                                                  ‘clean up after yourself
There is also the option of going to a custom control. There are several large text listboxes listed in the File Archives page of Ask the VB Pro.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes