Option Explicit 'Note that the indexing for the returnArray array is et up for 1-based indexing. Sub ParseLine(dataLine

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Option Explicit 'Note that the indexing for the returnArray array is et up for 1-based indexing. Sub ParseLine(dataLine

Post by answerhappygod »

Option Explicit Note That The Indexing For The Returnarray Array Is Et Up For 1 Based Indexing Sub Parseline Dataline 1
Option Explicit Note That The Indexing For The Returnarray Array Is Et Up For 1 Based Indexing Sub Parseline Dataline 1 (73.08 KiB) Viewed 27 times
Option Explicit Note That The Indexing For The Returnarray Array Is Et Up For 1 Based Indexing Sub Parseline Dataline 2
Option Explicit Note That The Indexing For The Returnarray Array Is Et Up For 1 Based Indexing Sub Parseline Dataline 2 (63.56 KiB) Viewed 27 times
Option Explicit 'Note that the indexing for the returnArray array is et up for 1-based indexing. Sub ParseLine(dataLine As String, delimiter As String,. Nvalues As Integer, returnArray() As String) 'This sub parses a line of data from the text file into individual pieces of data. 'It returns an array of the pieces of data and number of pieces (in nValues). Dim i As Integer Dim char As String Dim counter As Integer ' counts the pieces of data in the line Dim currrentText As String ' text since last comma 'Counter counts the number of pieces of data in the line. counter = 1 ReDim returnArray(counter) 'currentText is any piece of data in the line, where the pieces are separated by commas. CurrentText = "" Go through the string a character at a time. For i = 1 To Len(dataLine)
'Get the character in position i. char = Mid(dataLine, i, 1) End Sub 'Check if the character is a comma or the last character in the string. If char = delimiter Then returnArray(counter) = currenttext Next i 'Get ready for the next piece of data. currentText = "" counter = counter + 1 ReDim Preserve returnArray(counter) Elself i= Len(dataLine) Then Else 'Capture this last piece of data and return the number of pieces. currentText = currentText & Mid(dataLine, i, 1) End If returnArray(counter) = currenttext nValues = counter Add this character to the currenttext string. currentText = currenttext & Mid(dataLine, i, 1)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply