Finding the End of a Word

Finding the End of a Word

I am new to VB and must learn it by yesterday! I am working with text strings and must figure out how to pull words from a line by an ACSII character that changes. So far I am opening a text file for sequential input and testing for the required character line by line, however, how do I find the beginning and end of the word and send the “word” to output?

Well, you can probably check for a piece of punctuation, like a space or something. The InStr function can look in a string for a particular character. If you know for sure that you don’t have punctuation and just spaces, it will be very quick.

In order to pull the actual word out of the string you can use the Mid (aka Mid$) function. For instance, let’s say you want to pull the “username” out of some text data. You know that it will say “Username:”, then a space, then the username itself, followed by another space. We’ll say that the string you’ve read in from the file is already in the variable “WorkString” The code would look something like this:

Dim temp As StringDim Name As StringDim Startpoint As Integer’this line sets the point in the line where you’re going to start pulling out the characters of the name’it looks for the colon and then adds one for the space and one more for the actual first letter of the nameStartpoint = InStr(WorkString, “:”) + 2’now we’re going into a Do/LoopDo  ‘pull out the first character here.  this line says “Go to the startpoint in workstring and retrieve one letter  temp = Mid(WorkString, Startpoint, 1)    If temp <> ” ” Then                ‘This line checks to see if it’s a space (i.e. the end of the name)      Name = Name & temp          ‘if not, it adds it to the Name string      Startpoint = Startpoint + 1    ‘and increments Startpoint by one for the next pass through the loop    Else      Exit Do                                 ‘if it is a space, we exit from the do loop.    End IfLoop

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