|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
need help reading contents of a file into an array...SKYPE ME.I've got a .txt data file with a name, pin, balance seperated by commas. I am opening the file and using Split to split it between the ,'s I need to read it into an array and then check if what was entered as a name by the user is in the array. Can anyone be of help? Please Skype me, using the Text chat of skype. I can transfer code just using text.....I have the code written but I dont think I am doing something right because whenever I enter a name it is coming back as invalid. At this point I am not even sure if I have the array built. Skype name: vbnethelp Or if someone could show me how to make an array reading from a file that is seperated by commas as above and would contain 10 records. thank you. Jason
Are you using VS 2005? If so, this is available as one of the code snippets (under File System). Dim filename As String = "C:\Test.txt" Dim fields As String() Dim delimiter As String = "," Using parser As New TextFieldParser(filename) parser.SetDelimiters(delimiter) While Not parser.EndOfData ' Read in the fields for the current line fields = parser.ReadFields() ' Add code here to use data in fields variable. 'e.g. fields(0) would be your Name field End While End Using HTH Richard Show quoteHide quote "Jason" wrote: > Could anyone spare some time and try to help me out. > > I've got a .txt data file with a name, pin, balance seperated by commas. I > am opening the file and using Split to split it between the ,'s I need to > read it into an array and then check if what was entered as a name by the > user is in the array. > > Can anyone be of help? Please Skype me, using the Text chat of skype. I > can transfer code just using text.....I have the code written but I dont > think I am doing something right because whenever I enter a name it is > coming back as invalid. At this point I am not even sure if I have the > array built. > > Skype name: vbnethelp > > Or if someone could show me how to make an array reading from a file that is > seperated by commas as above and would contain 10 records. > > thank you. > > > VS.Net 2003 that is what I have here.
Show quoteHide quote "Richard Bysouth" <sloth@nospam.nospam> wrote in message news:4C628E6A-5A61-4295-B00D-4A223BC3B4BA@microsoft.com... > Jason > > Are you using VS 2005? If so, this is available as one of the code > snippets > (under File System). > > Dim filename As String = "C:\Test.txt" > Dim fields As String() > Dim delimiter As String = "," > > Using parser As New TextFieldParser(filename) > parser.SetDelimiters(delimiter) > > While Not parser.EndOfData > ' Read in the fields for the current line > fields = parser.ReadFields() > > ' Add code here to use data in fields variable. > 'e.g. fields(0) would be your Name field > > End While > End Using > > HTH > > Richard > > > "Jason" wrote: > >> Could anyone spare some time and try to help me out. >> >> I've got a .txt data file with a name, pin, balance seperated by commas. >> I >> am opening the file and using Split to split it between the ,'s I need >> to >> read it into an array and then check if what was entered as a name by the >> user is in the array. >> >> Can anyone be of help? Please Skype me, using the Text chat of skype. >> I >> can transfer code just using text.....I have the code written but I dont >> think I am doing something right because whenever I enter a name it is >> coming back as invalid. At this point I am not even sure if I have the >> array built. >> >> Skype name: vbnethelp >> >> Or if someone could show me how to make an array reading from a file that >> is >> seperated by commas as above and would contain 10 records. >> >> thank you. >> >> >> Hi Jason,
Please post your code here, so someone can review it and let you know what minor error exists. Regards, Cerebrus. Show quoteHide quote "Jason" <none@none.invalid> wrote in message news:uP6i8OpMGHA.3408@TK2MSFTNGP12.phx.gbl... > VS.Net 2003 that is what I have here. > > "Richard Bysouth" <sloth@nospam.nospam> wrote in message > news:4C628E6A-5A61-4295-B00D-4A223BC3B4BA@microsoft.com... > > Jason > > > > Are you using VS 2005? If so, this is available as one of the code > > snippets > > (under File System). > > > > Dim filename As String = "C:\Test.txt" > > Dim fields As String() > > Dim delimiter As String = "," > > > > Using parser As New TextFieldParser(filename) > > parser.SetDelimiters(delimiter) > > > > While Not parser.EndOfData > > ' Read in the fields for the current line > > fields = parser.ReadFields() > > > > ' Add code here to use data in fields variable. > > 'e.g. fields(0) would be your Name field > > > > End While > > End Using > > > > HTH > > > > Richard > > > > > > "Jason" wrote: > > > >> Could anyone spare some time and try to help me out. > >> > >> I've got a .txt data file with a name, pin, balance seperated by commas. > >> I > >> am opening the file and using Split to split it between the ,'s I need > >> to > >> read it into an array and then check if what was entered as a name by the > >> user is in the array. > >> > >> Can anyone be of help? Please Skype me, using the Text chat of skype. > >> I > >> can transfer code just using text.....I have the code written but I dont > >> think I am doing something right because whenever I enter a name it is > >> coming back as invalid. At this point I am not even sure if I have the > >> array built. > >> > >> Skype name: vbnethelp > >> > >> Or if someone could show me how to make an array reading from a file that > >> is > >> seperated by commas as above and would contain 10 records. > >> > >> thank you. > >> > >> > >> > > Jason,
You can use for this OleDB and read than with some instructions the complete file in a dataset. Have a look at this sample on our website. http://www.vb-tips.com/default.aspx?ID=1b644f6b-aa01-49f6-bc1f-212f9e0de193 I hope this helps, Cor Show quoteHide quote "Jason" <none@none.invalid> schreef in bericht news:%23DrrlnoMGHA.2916@tk2msftngp13.phx.gbl... > Could anyone spare some time and try to help me out. > > I've got a .txt data file with a name, pin, balance seperated by commas. > I am opening the file and using Split to split it between the ,'s I need > to read it into an array and then check if what was entered as a name by > the user is in the array. > > Can anyone be of help? Please Skype me, using the Text chat of skype. I > can transfer code just using text.....I have the code written but I dont > think I am doing something right because whenever I enter a name it is > coming back as invalid. At this point I am not even sure if I have the > array built. > > Skype name: vbnethelp > > Or if someone could show me how to make an array reading from a file that > is seperated by commas as above and would contain 10 records. > > thank you. >
array - how do you get the number of dimensions?
Resize problem (in IDE) Barcode Reader Application -- HELP Unmanaged DLL Callback - Program Unexpectedly Quits tab function in a multiline text box Com+ and asp.net? DimeAttachment save to disk Moving Rectangle within a PictureBox Control Interface creation in VB.Net 2005 Connection Properties Dialog Box? |
|||||||||||||||||||||||