Textfile Import (With Delimiter)

Import Text-Files with delimiter
Dim DB As NotesDatabase
Dim Doc As NotesDocument
Dim Item As NotesItem


Sub Click(Source As Button)
Dim s As New NotesSession
Set Db = s.CurrentDatabase

' Open a file, print it, and close the file.
Dim text As String, fileNum As Integer
fileNum% = Freefile()
Dim Daten As Variant
Open "d:\daten.txt" For Input As fileNum%
Do Until Eof(1)
Line Input #1, text$

' String in Einzelwerte splitten
Daten = Split(Cstr(text$),";")
'Msgbox Daten(3)
Set Doc = Db.CreateDocument

Set Item = Doc.ReplaceItemValue("BKR",Daten(0))
Set Item = Doc.ReplaceItemValue("Werk",Daten(1))
Set Item = Doc.ReplaceItemValue("ArtikelNr",Daten(2))
Set Item = Doc.ReplaceItemValue("ArtikelBez",Daten(3))
Set Item = Doc.ReplaceItemValue("Basismenge",Daten(4))
Set Item = Doc.ReplaceItemValue("Basismengeneinheit",Daten(5))
Set Item = Doc.ReplaceItemValue("KopfG?ltigVon",Daten(6))
Set Item = Doc.ReplaceItemValue("KopfG?ltigBis",Daten(7))
Set Item = Doc.ReplaceItemValue("Komponente",Daten(8))
Set Item = Doc.ReplaceItemValue("Komponentenbezeichnung",Daten(9))
Set Item = Doc.ReplaceItemValue("Einsatzmenge",Daten(10))
Set Item = Doc.ReplaceItemValue("Einsatzmengeneinheit",Daten(11))
Set Item = Doc.ReplaceItemValue("KompG?ltigVon",Daten(12))
Set Item = Doc.ReplaceItemValue("KompG?ltigBis",Daten(13))
Set Item = Doc.ReplaceItemValue("Form","Komponente")

Call Doc.save (True, True)
Loop
Close fileNum%
End Sub

Function split(strSource As String, strItemDelim As String) As Variant

Dim astrReturn() As String ' The array to return

Dim intElement As Integer ' The array element currently being set
Dim z_intItemCount As Integer ' The total number of elements for the array
Dim z_intStartOfItem As Integer ' The start position of the item in the
' source string.
Dim z_intEndOfItem As Integer ' The end position of the item in the source
' string.

Dim z_strCurItem As String ' The currently parsed item
Dim z_strRemaining As String ' The remaining string to cycle through
Dim z_strStartOfItemBack As String ' The rest of the string, from the
start of
' the item on back.
'*** End Variable
Declarations ***

' Put the source string
into a holder:
z_strRemaining = strSource

' Cycle through the
source string and get a
' count of elements:
While (Not z_strRemaining = "")
z_intStartOfItem = Instr(1, z_strRemaining, strItemDelim)

If (z_intStartOfItem <> 0) Then
z_intItemCount = z_intItemCount + 1
z_strRemaining = Mid(z_strRemaining, z_intStartOfItem +
Len(strItemDelim), _
Len(z_strRemaining))
Else
z_intItemCount = z_intItemCount + 1
z_strRemaining = ""
End If
Wend

' Size the return array
so that it can hold
' all of the elements:
Redim astrReturn(z_intItemCount - 1)

' Reset the holder to
the value of the source string:
z_strRemaining = strSource

' Cycle through the
source list, parsing the
' string into
individu
This was first published in November 2000

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close