vb.net - How To Read From Text File & Store Data So To Modify At A Later Time -


What am I trying to do that might be better for using SQL Server but I have used several applications in the past Have seen that only work on text files and I want to try copying the behaviors that follow those applications.

I have a list of URLs in the text file. It is easy to open and read lines through this line, but how can I archive additional data from the file and query the data?

Example text file:

  http://link1.com/ - 0 http://link2.com/ - 0 http://link3.com / - 1 http://link4.com / - 0 http://link5.com/ - 1   

Then I will read the data on:

  Private Sub Button X2_Click (.bybject as Byval Sender System, as ByVal E System.EventArgs) ButtonX2.Click OpenFileDialog1.Filter = "* txt Text Files | * .txt" manages OpenFileDialog1.ShowDialog () = DialogResult.OK then retarded as AllText String = My.Computer.FileSystem. ReadAllText (OpenFileDialog1.FileName) Dim Lines () = Split (AllText, vbCrLf) Dim List = New List (Test) Dim URLLoaded as Integer = 0 for I = 0 UBound (Line) for Lines (i) = "" Then continue for the string for slow URLInfo () = Split (lines (i), "-") if URLInfo.Count & lt; 6 Then continue to list.Add (New Test (URLInfo (0), URLInfo (1)) URLsLoaded + = 1 Next DataGridViewX1.DataSource = List LabelX5.Text = URLsLoaded.ToString () End then End Sub   

As you can see above, from above I am encouraging the user to open a text file, later it is displayed to a user in a datagrid witch.

Now this is my problem, I want to be able to query the data, example * Choose from the URL active WHERE = '1' (also used for PHP + MySQL!)

Where the URL in Text 1 is 1 or behind 0.

In the above example, data is being stored in a simple class as follows:

  public class test public all new (same URL as string, in the form of integer By activating) _URL = url _active = active end sub personal _URL string as public property url () string return _URL termination set (byVal value string) _URL = Go value end date set property Get String Public Property String as Private _Active Get _Active End Go Set (active as ByVal value as string) _active = value and set end and property and class   

Do I After importing from a text file, going completely wrong about caching data?

I am learning new and still fundamentals for VB.NET, but it seems very easy to learn to play before killing heavy books!

job example:

  myurls of new list (test) Add (New Test ("http://link1.com/", 1)) myurls.Add (New Test ("http://link2.com/", 0)) Myurls.Add (New Test ("http : //link3.com/ ", 0)) Dim result = myurls where t.ctct = 1 test as test for each testitem resulted in MsgBox (testitem.URL) next   

By the way, LINQ magic is that you can shorten your shipment / parsing code in 3 rows of code:

  dim lines () = IO.File.ReadAllLines ("myfile. Txt ") slow myurls = (In the form of test) (select the new test in lines (split (from t, to -) (0), split (t, "-") (1)) ToList DataGridViewX1.DataSource = myurls   <. P> The first line reads all the lines of the file in an array of strings; the second row divides each row into the array, and creates a test object, and then converts all those results into a list.  

Of course, foolishness can be misused by using it one line: er:

  DataGridViewX1.DataSource = (from the IO.File.ReadAllLines ("myfile.txt Select "New Test" (Split (T, "-") ( 
  if OpenFileDialog1.ShowDialog () = DialogResult.OK then from DataGridViewX1.DataSource = (IO.File.ReadAllLines (" Myfile.txt ") Select new test (split (t," - ") (0), split (t," - ") (1)). ToList LabelX5.Text = ctype (DataGrVidView 1Datasource, list (test Of)). End count if    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -