Manage Learn to apply best practices and optimize your operations.

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 (True, True)
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), _
z_intItemCount = z_intItemCount + 1
z_strRemaining = ""
End If

' 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

Dig Deeper on Domino Resources - Part 6



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury