I have this code but it doen't work
there is a problem on this
huidigegeg = geg(i).Split(("|--|"))
Somebody now how this come
Dim huidigegeg(7) As String
Dim teller As Integer
Dim i As Integer
Dim geg(i) As String
Dim strGegeven As String
Dim strAlles As String
Dim intNr As Integer = FreeFile()
FileOpen(intNr, accijns, OpenMode.Input)
Do
Input(intNr, strGegeven)
'strAlles &= strGegeven & vbCrLf
ReDim Preserve geg(index)
geg(index) &= strGegeven & "|--|"
If teller Mod 7 And teller <> 0 Then
index += 1
End If
teller += 1
Loop Until EOF(intNr)
For i = 0 To geg.Length - 1
huidigegeg = geg(i).Split(("|--|"))
Next

Problem with array
penta
Looking at your code there are some questions and suggestions that may assist you in finding your answer.
What are you actually trying to do (Let us know what your are trying to do rather than a simple this code is not working - how do we know what you are trying to achieve)
What is not working Be more descript, is it an exception or is it that the result is not what you expect.
Now for some ways that may help you find out whats occuring here and correct it.
1. Put some error handling in here to see if an exception is occuring (Try..Catch)
2. Dont' dimension the string array specific to 7 elements - what happens if you have 8 or 9 elements it will throw an exception. This may be dependent upon the file contents you are using.
3. What are you trying to do in the loop . This is a array of strings which result in you able to look at the contents of each element. Which this code appears to work on with a file I created.
4. The process is obviously dependent upon a file - what are the contents of this file.
Dim huidigegeg() As String
Dim teller As Integer
Dim i As Integer
Dim geg(i) As String
Dim strGegeven As String = ""
Dim strAlles As String
Dim intNr As Integer = FreeFile()
Dim index As Integer
FileOpen(intNr, "C:\test.txt", OpenMode.Input)
Try
Do
Input(intNr, strGegeven)
ReDim Preserve geg(index)
geg(index) &= strGegeven & "|--|"
If teller Mod 7 And teller <> 0 Then
index += 1
End If
teller += 1
Loop Until EOF(intNr)
For i = 0 To geg.Length - 1
huidigegeg = geg(i).Split("|--|")
For Each strOP As String In huidigegeg
Console.WriteLine(strOP.ToString)
Next
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
FileClose(intNr)
CadsKiran
http://svekke.sin.khk.be/Teruggave%20Accijns.rar
This is one line
" 12.900 ","00060003","02/01/06","LT ","0469627082HD001","BVBA BELGICACTUS","01"
And this i wrote in an array
But after i wrote one line in an array,i need something from that line
like 12.900 and 00060003 and 02/01/06 and i went that also in an array
So i can write it to an excel file
guariox
The objectreference is not on a example of a object adjusted.
Something like this
AlanMusicMan
Please try to give us the exact exception message.
Was it a System.NullReferenceException with the message Object reference not set to an instance of an object.
As trucker said - we need the file, we need specific details on the problem and what your trying to do - the other thread wasnt particularly enlightening as it related to an Excel problem. This is obviously reading a text file and processing it.
So we really want a good description of what your trying to actually do and the specifics of the problem you are getting. What exception message, what line. What Inputs your giving it. As both trucker and me have run your code and the code seems to work. I would suspect that there is a logic issue or something in you input data that isnt being correctly dealt with by the current logic in you code.
However without a clear description of what you trying to do, the files your using and the problems your getting its difficult to provide a solution.
Jamsey
VICTORLU
I have ran your code sample and opened a test file with the name: test.txt and I do not get any errors. As mentioned above, exactly what problem are you having besides the error you mentioned What kind of data is in the text file that is not being proccessed properly It could be the problem exists in your "test.txt" file and not with your code. Provide a sample of the data in the text file that is not being proccessed correctly. That would help us help you.
james
aka:Trucker
rumi500
hi,
i just hope all your lines hold the same pattern with exact number of fields at least
you can use streamreader to read from the file, regex to split the line to fields , you can save it in an arraylist if you don't know the number of lines in that file but if you know it you can use string array instead anyway you can do something like this
Imports System.IO Imports System.Collections Imports System.Text.RegularExpressions
Module Module1
Dim myarray As New ArrayList()
Dim splitters As Regex = New Regex(""",""")
Dim removechars() As Char = {"""", " "}
Sub Main()
Using sr As New StreamReader("textfile1.txt")
Dim line As String = Nothing While (Not sr.EndOfStream)
line = sr.ReadLine()
line = line.Trim(removechars)
Dim myline() As String = splitters.Split(line)
myarray.Add(myline)
End While End Using 'for testing Dim x, y As Integer For x = 0 To myarray.Count - 1
Dim oneline() As String = myarray(x)
Console.WriteLine("line number {0}", x + 1)
For y = 0 To oneline.Length - 1
Console.WriteLine(oneline(y))
Next Next End Sub
End Module
hope this helps
Rob Selby
I need it very quickly
agerman77
De objectverwijzing is niet op een exemplaar van een object ingesteld!
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=351075&SiteID=1
look here
I need it for this
read a txt bestand
MVP_mayank
Hi,
Is your problem solved
Thank you,
Bhanu.
ShawnT123
Can we get this error in English