String VB6 for integers for headers

I am trying to parse a CSV file in a VB6 application to update multiple records in a SQL table with an existing form code for writing a single record. CSV files will have a whixh header line, which can be used to check for information coming to the right place in the ADODB record set. In C ++, you can use a map to say how

map<String s, int x> column 
 column<"First Name", -1>
 column<"Last Name",-1>

Then create a counter through comma-separated values, where if the third value is Last Name, then the code can be written to change column <"Last Name", - 1> to column <"Last Name", 3>, and if x ! = -1 on any of the cards, the file is valid for use, I would then scroll through the remaining entries and parse their container using something similar to

strLastName = Array<column[3]>

to assign record values ​​to the correct variables. I'm still very new to VB6, how can I do something like this in VB6 and which containers should I use? Still i

Public Sub GetImportValues()
On Error GoTo GetImportValues_Error:
Dim intFileNum As Integer

Open Path For Input As #intFileNum

Do Until EOF(intFileNum)

Line Input #intFileNum, vbCrLf

FunctionThatSavesInformationToSQL

Loop

Close #intFileNum



GetImportValues_Exit:
    Exit Sub

GetImportValues_Error:
    Err.Source = "frmMemberAdd.GetImportValues" & " | " & Err.Source
    Err.Raise Err.Number, Err.Source, Err.Description
End Sub

with a dialog box returning the path as a string using App.path in a separate function

*****************************************.... *** Minor change in answer The collection was aware of what I requested, but I had to change it to a dictionary, because you cannot return items to collections that prevented me from comparing items and changing keys, but the dictionary can. Make sure you use the dictionary that you switch the item and the key.

+4
source share
1 answer

, (Dictionary<string, int> #). VB6 Collection - # Dictionary<string, object>. String Variant. :

Dim oColl As Collection

Set oColl = New Collection
oColl.Add -1, "ColumnName"

Dim nColumnIndex As Long

'Get column index for column name.
nColumnIndex = oColl.Item("ColumnName")

If nColumnIndex = -1 Then
    nColumnIndex = ...

    'When you want to update a column index in the collection, you
    'first have to remove the item and then add it back with the right
    'index.
    oColl.Remove "ColumnName"
    oColl.Add nColumnIndex, "ColumnName"
End If

1:

VB6: :

Dim oObj As New SomeClass

VB.Net, VB6. , , oObj Nothing . ( ) , , .

:

Dim oObj As SomeClass
Set oObj = New SomeClass
...

'Clean up the object when you're done with it. Remember, there's
'no garbage collection in COM / VB6, you have to manage object
'lifetimes.
Set oObj = Nothing

, Long Integer , - Long - 32- , Integer - 16 . VB6 . ( , ).

.NET Dictionary COM: VB6. , () , Collection, VB6 .NET Framework.

2:

@CMaster, Dictionary Microsoft Scripting Runtime - , ( Collection - ). , .

+4

All Articles