473,785 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about Text Boxes

I have a multiline textbox with 10 lines of text in it. I want to search
Line by Line for the word" [Option]". How do I process one line in a text
box at a time? I DON'T want to just search the whole textbox for my word,
because when I find it, I want to stop the cursor there until the user
decides to continue to find the next instance.

MY QUESTION IS: How can I search for text line by line in a textbox?

Thank You,
Paul
Jul 17 '05 #1
2 2863
On Wed, 23 Jun 2004 23:50:55 -0700, "Newsgroup" <pm*@swannack.n et>
wrote:
I have a multiline textbox with 10 lines of text in it. I want to search
Line by Line for the word" [Option]". How do I process one line in a text
box at a time? I DON'T want to just search the whole textbox for my word,
because when I find it, I want to stop the cursor there until the user
decides to continue to find the next instance.

MY QUESTION IS: How can I search for text line by line in a textbox?


Option Explicit
' Add one Textbox
' Set it to MultiLine

Private Declare Function SendMessage Lib _
"user32" Alias "SendMessag eA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function SendMessageStr Lib _
"user32" Alias "SendMessag eA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long

Private Const EM_GETLINECOUNT = &HBA
Private Const EM_GETLINE = &HC4
Private Const EM_LINELENGTH = &HC1
Private Const EM_LINEINDEX = &HBB
Private Sub Command1_Click( )
Dim Lines&, S$, P&, L&
Const LINE_NO = 2

' --- Count the Lines
Lines& = SendMessage(Tex t1.hwnd, _
EM_GETLINECOUNT , _
0, _
0)
Me.Print Lines
' Note: If Text1.Text = "" then 1 is returned

' --- Now get position of start of 2nd line
' this is zero based
P& = SendMessage(Tex t1.hwnd, _
EM_LINEINDEX, _
LINE_NO - 1, _
0)
Me.Print "Line 2 Starts at:"; P
' --- Now Get its Length
L& = SendMessage(Tex t1.hwnd, _
EM_LINELENGTH, _
P, _
0)
Me.Print "Length of Line 2 is:"; L
' --- Now Get Line 2
S$ = Space$(L)
L& = SendMessageStr( Text1.hwnd, _
EM_GETLINE, _
LINE_NO - 1, _
S)
Me.Print S$
' --- And to prove it
Me.Print Mid$(Text1.Text , P + 1, L)

End Sub

Jul 17 '05 #2
> I have a multiline textbox with 10 lines of text in it. I want to
search
Line by Line for the word" [Option]". How do I process one line in a text box at a time? I DON'T want to just search the whole textbox for my word, because when I find it, I want to stop the cursor there until the user
decides to continue to find the next instance.

MY QUESTION IS: How can I search for text line by line in a

textbox?

I'm not sure why you don't simply want to skip down through all the
words you want to find. Put the following code in a CommandButton and
load up your TextBox with text containing the word you want to find (in
this case, " [Option]", with the leading space as shown). Now keep
pressing the button and watch the TextBox.

Rick - MVP

Dim Position As Long
Dim WordToFind As String
WordToFind = " [Option]"
With Text1
If .SelLength Then .SelStart = .SelStart + .SelLength
Position = InStr(.SelStart + 1, .Text, WordToFind)
If Position Then
.SelStart = Position - 1
Else
.SelStart = InStr(.Text, WordToFind) - 1
End If
.SelLength = Len(WordToFind)
.SetFocus
End With

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3814
by: Lance Geeck | last post by:
Hi, I am trying to learn the VB.NET approach and am having problems with updating the database. What I have is a simple windows form using text boxes for entering name, address and phone. It is using a web service to load the dataset and update the data. Here is what I am doing. I have an existing record in the database. I created a datagrid bound to the dataset.
7
1446
by: jimi_xyz | last post by:
I am kind of new to C sharp; I have a quick question I have multiple text boxes 12 of them to be exact. What I want to do is fill them with values that are in a array of integers. The way I am currently doing this is like this.. input0.Text = Convert.ToString(arr); input1.Text = Convert.ToString(arr); input2.Text = Convert.ToString(arr); input3.Text = Convert.ToString(arr); input4.Text = Convert.ToString(arr);
3
1642
by: eBob.com | last post by:
I have several applications which mine web sites for personal information which they publish. They publish the info in one form, I transform the info into Excel spreadsheets. So all these programs pick up name, telephone number, age, sex, etc.. And as they pick up the information they display it in text boxes. The text boxes are display only, and the info is displayed only for debugging purposes. Right now I have a lot of duplicate...
0
1159
by: Brian Cesafsky | last post by:
I am using framework 1.1 I have a user control and a web page. I want to set up properties on the user control, so I can access the text boxes on the user control when I am in the code behind page of the 'main' web page. I have done this so far...
0
978
by: Brian Cesafsky | last post by:
I am using framework 1.1 I have a user control and a web page. I want to set up properties on the user control, so I can access the text boxes on the user control when I am in the code behind page of the 'main' web page. I have done this so far...
9
3183
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
1
1125
by: JDeats | last post by:
So I have a new WebForm created in VS.NET 2005 that's in the default "flow layout". I have a dropdown list box followed by HTML break- return <brtags and two two text boxes, below the text boxes I have a command button. I have set the text boxes Visible property to False when the page loads there is empty space where this controls would be if they are visible. The behavior I'm looking for is to have the space dispear the command button...
15
2718
by: Matthew | last post by:
Hi, I'm mainly a coder, PHP at the moment, but from time to time need to design and use some css. I've a css text alignment issue. Mostly to align text neatly in the past I've used tables. But now I know I should be getting into the 21st C and using css properly. Here are 2 mock up pages with some forms on them, obviously I want the
2
1522
by: Lynx101 | last post by:
Hi, Is this a stupid question? Senario: Two tables linked together with an ID number. Question: When using a combo box, which refences another table by indexed autonumber, is there a way to copy the returned text value to a text field. I have many combo boxes and after the value changes I would like a normal text field to show the returned text value, regardless of which combo box was changed.
25
5404
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.