Find A String On 2 Seperate Lines
Mar 10, 2009
Hi.
Im using this little function to search for text within some downloaded HTML source:
Public Function GetStringBetween(ByVal InputText As String, _
ByVal starttext As String, _
ByVal endtext As String)
Dim lnTextStart As Long
Dim lnTextEnd As Long
lnTextStart = InStr(StartPosition, InputText, starttext, vbTextCompare) + Len(starttext)
lnTextEnd = InStr(lnTextStart, InputText, endtext, vbTextCompare)
If lnTextStart >= (StartPosition + Len(starttext)) And lnTextEnd > lnTextStart Then
GetStringBetween = Mid$(InputText, lnTextStart, lnTextEnd - lnTextStart)
Else
GetStringBetween = "ERROR"
End If
End Function
It works great, but i need to be able to search for something that spans over 2 lines. E.g.
Sam works in a shop from the hours
of 09:00 to 15:00
I want to search for the words "hours of" - but because they are on seperate lines, it cannot find it.
I have tried "hours" & Environment.NewLine & "of" - and other variants of envirmonment.newline (knowing they all return the same value, but, hey, you gotta try) but to no avail. Surely there must be some sort of syntax to ge around this?
Any ideas?
View 5 Replies
ADVERTISEMENT
Mar 21, 2009
1. i added a datagrid at runtime on a form. i want to bind a datasource to the datagrid in a button's click event handler, but the datagrid doesn't seem to be visible anywhere else outside the form load event where it is declared. how can i find the datagrid control?
2. and another beginner question.. how to i declare a string that spans multipe lines? i tried with the + operator like in c#, but it doesn't work.
View 3 Replies
Feb 27, 2010
I have a program where a user puts a string into a textbox, and then character one goes into Textbox1, char2 goes into TB2, char3 goes into TB3, etc.I have a For loop that gets all of my textboxes that are used for this, and I have my for loop that is supposed to go through my string character by character.[code]
View 7 Replies
Sep 30, 2009
I have a string full of html & which reads
Dim strHml as string = "<html><head><title></title></head><body><div class="normal">Dog</div>
<div class="normal">Cat</div><div class="normal">Elephant</div><div class="normal">Giraffe</div><div class="normal"><div><p>Random Div</p></div>Lion</div><div>Wolf</div>
<div>Tiger</div></body></html>"
I want to somehow be able to pull all the div tags and their content and put each one into an array have looked at split function and regular expressions but no clear and easy solution has presented itself as yet.I have amended this slightly to incorporate nested div tags, but those tags I still need returning in the format :-
<div class="normal"><div><p>Random Div</p></div>Lion</div>
View 1 Replies
Jul 1, 2010
I did this before, but i totally forgot how to do it.I have an array, the array contains strings with 2 seperators.like so:
name1 / name2 / name3
Basicly i want name1, name2, and name3 in 3 seperate lists, or arraylists. But, i don't know how to do it.Each line is being read from a file.
View 15 Replies
Aug 26, 2011
I want to draw string in multiple lines and and I want to know how many lines given string will take. I am using following method.
[Code]...
View 1 Replies
May 16, 2012
i have a txt file:
118.97.75.226:8080,
218.14.227.197:3128
118.96.151.110:8080
219.83.100.205:8080
this in an array, how do i find how many lines are in this array (obviously there is 4 but i want it to automatically detect it because it may not always be four if i import a differnt txt file)
Dim lines() As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lines = IO.File.ReadAllLines("fileName.txt")
Label1.Text = lines(0)
[code]....
View 1 Replies
Jun 8, 2011
How to find Lines of Code in VS 2010?
View 7 Replies
Aug 22, 2010
I need to go line by line through a text file as well as a listbox and remove lines over x amount of characters as well as adding the number of skipped lines to a label. I am trying to use a listbox in this example but it is not working correctly. What I am I doing wrong? First it will only remove an item when it is highlighted (focused) how can I make it so that is not required?[code]...
View 7 Replies
Jun 9, 2012
I know this is a very noob question but would it be possible to find a word in my coding and replace it with three lines?
[Code]...
So far I can only replace it with "ex1.Message) Finally Application.exit" but it's going to take me forever to go through my coding to change it. I'm not sure what character I could use to start a new line in between "ex1.Message)" and "Finally" and "Application.exit"
View 1 Replies
Oct 6, 2010
Currently we have a large DataTable (~152k rows) and are doing a for each over this to find a sub set of distinct entries (~124K rows). This is currently taking about 14 minutes to run which is just far too long.
As we are stuck in .NET 2.0 as our reporting won't work with VS 2008+ I can't use linq, though I don't know if this will be any faster in fairness.
Is there a better way to find the distinct lines (invoice numbers in this case) other than this for each loop?[code]....
View 1 Replies
Aug 4, 2011
I have a program that will read a text file and put information from the text file into multiple text boxes. What I am trying to do now is be able to change the values in the textboxes and be able to write the specifc changes back to the text file. One way I though of doing that was using a while loop and copy the lines of the text file to another text file, then when it finds the line that has the specific change from the text box, make the change and continue writing the line until it reaches the end of the file. Then I was going to copy the file and overwrite the original, escientally making the change to the new file. Right now it will make the new file but will just make a blank text file. I think the problem is in the while loop statement but I am not sure. Here is the code below:
Code:
Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submitButton.Click
Dim trackname As String
[Code].....
View 1 Replies
Jun 4, 2009
I am suing VB 2008 express edition.
I am trying to solve this problem since many days. The problem seems to be rather mathematical, but I faced difficulties dealing with Grids and how to store them using visual basic.
[URL]
In my problem, I have a world of 200 x 200 units divided into 4 x 4 grids (Each of 50 units).
There is a line crosses some areas has the coordinates of Point A (Starting Point) of (XA = 12.43, BA = 159.48) and Point B coordinates (Ending Point) of (XB = 112.95, YB = 20.95).
The question is, how can find the length of (A to C1), (C1 to C2), (C2 to C3), (C3 to C4), (C4 to C5) and finally (C5 to B)?
In addition, how can I indicate the square in which the line is inside?
note that the method should work for all conditions (-ve and +ve line slopes) and for different A and coordinates.
View 1 Replies
Apr 19, 2011
A
/n
/n
/n
.
.
B
Now there can be n no of lines between a and b have to find such content and remove A and B
View 1 Replies
Jun 11, 2011
Greetings,
My app saves a bunch of stuff to an XML file. This is my line of code-
Using writer As XmlWriter = XmlWriter.Create("C:vdx2kMWSREEXTReportsInboxTK" & frmCitation.txtCiteNumber.Text & "Traff.xml", settings)
So that saves it at that specific location.
I need to duplicate the XML and have it also save in another location. I've been at this for days, Googling, searching, trying different things and now I need to turn here for help.
Any ideas?
View 2 Replies
Mar 6, 2010
i wish to run a program with 2 forms form 1 will have 2 radio buttons and a textbox and form 2 will have 2 textboxs i wish to use the radio buttons to select wich information is bieing displayed from either form2 textbox1 or textbox2 using the radio buttons on form1 then display the information in textbox1 of form1.
View 4 Replies
Aug 4, 2011
How do i go about making variables on a second form have the same value as in the first form while still being able to make the variable on the first any given word or phrase and it appear the same on the second form?
View 2 Replies
Jun 16, 2010
I'm trying to open a connection and create an SQL statement with two different tables in different Access DBs. Is this possible? I'd like to join the tables in a query.
Is there a great advantage in splitting somewhat large Access databases? Or is it best to just create a large access database with many tables?
View 3 Replies
Feb 19, 2010
Basically I try to get a DataGridView and a BindingSource working inside a class. I define them by:
Dim TempDGV3 As DataGridView = New DataGridView
Dim TestBinding As BindingSource = New BindingSource
When I manually add columns to the DataGridView, it works perfectly, but when I set it's DataSource to a bindingsource from a base class, it doesn't load data and keeps throwing 'object does not exist' errors. The bindingsource mentioned here did, however, work on other DataGridViews that are defined in the base class (and implemented in the form to which the base class belongs)
Same for the BindingSource(not the above mentioned, but the one I try to create inside the class in the beginning of this post). I try to use it in the following way:
TestBinding.DataSource = TempDGV3
TestBinding.Filter = filterString()
SourceDataGridView.DataSource = TestBinding
But the BindingSource keeps returning 'Nothing' for it's datasource and basically doesn't work. However, the SourceDataGridView mentioned here gets filled with 63 columns with "AllowUserToAddRows" and other properties when the columns names are asked.
So my question is: how do I get the BindingSource and the DataGridView to work in this class? I'm getting the feeling I'm missing out on something very obviously here. If that's not the case, I can report back with more code?
View 8 Replies
Sep 12, 2009
This is a very basic newbie question, but I still haven't worked it out yet. I have a fair amount of code that I want carried out inside my Form1_Mousemove event, but I also want the exact same code inside the Form1_MoveClick event. I assume the best solution is to take all of the code and put it inside a seperate procedure and call it from both events? Or is it possible to call one of the events manually so inside my Mouseclick event, could I force a call to the Mousemove event?
View 20 Replies
Jun 5, 2010
I'm relatively new to the vb.net framework and object oriented programming. After perusing the threads for a few hours I can't quite find an answer so I'm posting this thread. I'm not necessarily looking for code examples. I just want to know if it's possible and where to look next. Basically I'm trying to build a starter application that will help me learn programming. One of the main things I want to do is to be able to dynamically (at run time) create a set of information (data) that can be manipulated via a set of static (and/or dynamic) functions/calculations. The reason I need it to be dynamic is because even though this program is really just for my own fun and perusal on my own machine (and I want it to be able to run without any outside connections (i.e. databases or servers) the data itself is going to be location (i.e.State of residence or even city) specific. Essentially most of the data will be numerical and can be of the integer type. But I'd like to be able to adjust and create new data sets if desired. From everything I've read and researched I haven't found a way to do this (at least now without an excessive amount of coding that is above my expertise). So I want to know if there is a way to do this that is relatively simple.
View 2 Replies
Mar 14, 2011
txtBeautified.Text.Remove(txtBeautified.Text.LastIndexOf(","), 1)
i want to find the last index of "," in my text and then remove that , but it is not working. Any Idea? txtBeautified is a richtextbox.
View 3 Replies
Nov 21, 2010
asked other questions before this and they no longer need attencion.I am having trouble counting only lines with text in a string, and i need to see if there is a match between one string and a line in another multiline string.
View 10 Replies
Apr 26, 2010
i have been working on a project that requires to count the lines from a string like this is my code :
' On The Top
dim readdata as string
' in the func
dim read as new system.io.StreamReader(readstr)
readdata = Read.ReadToEnd
then i want that from every line in that file it executes like Shell(Line)
View 9 Replies
Mar 26, 2011
I have a string STR="CYHZ 262338Z 2700/2724 27012G22KT P6SM BKN040 TEMPO 2700/2710 5SM -SHSN BKN015 BECMG 2702/2704 28015G25KT FM271000 28018G28KT P6SM BKN040 BECMG 2722/2724 27012KT RMK NXT FCST BY 270300Z"
I want to put the new line characher before these words in the string(TEMPO, BECMG, FM, RMK) so that the output string look like this
[Code]...
View 2 Replies
May 5, 2009
How can i make a program that will read a text file (.txt) and save each seperate line as a variable? [cde]...
View 5 Replies
May 20, 2012
As Strings.Space Method , but instead space - new lines.For example:If I want 4 spaces, I can do:
space ("4")
But if I want 4 new lines,I have to do?:
VbNewLine & vbNewLine & vbNewLine & vbNewLine
Or there is another way and more effective? (such as "Strings.Space Method"for example)
View 3 Replies
Mar 26, 2010
I load a list of words in a string. How do I count the number of lines in that string via code?I'm trying to write a function like this:
Private Function CountLines(ByVal Data As String) As Integer
Count the number of lines in Data
End Function
View 2 Replies
Sep 10, 2011
Using VB.NET, Is there a way to do this RegEx call in 1 step... instead of 2-3? I'm trying to find the word "bingo", or whatever is between the START and END words, but then also inside the inner FISH and CAKES words. My final results should be just "bingo".
Dim s1 As String = "START (random string) FISH bingo CAKES (random string) END"
[Code]...
View 2 Replies
May 21, 2010
I have a large string variable that I'd like to split into multiple line for readability. What is the syntax to accomplish this?
EXAMPLE: Dim str As String = "asfrgasdfgadsfgadfgdfgasdfgdasfgdfgsdghsdghsh"
EXAMPLE: Dim str AS String = "asfrgasdfgadsfgadfgdfgasdfgd" _
"asfgdfgsdghsdghsh"
Something like that is what I'm trying to accomplish.
View 5 Replies