vba - Read entire ini section and put into array -


OK, so I have these functions that I'm turning to using for my VBA code. This is probably the case because it also happens with VBS.

The function (s)

  'Ini's announcements files to work with private promotional event GetPrivateProfileSection Lib "kernel32" Alias ​​_ "GetPrivateProfileSectionA" (ByVal as lpAppName string, as ByVal LpReturnedString string, as _Val nsize as long, ByVal lpFileName as string) long personal announcement function as GetPrivateProfileString Lib "kernel32" Alias ​​_ "GetPrivateProfileStringA" (ByVal lpApplicationName string In, byVal lpKeyName as any, _ ByVal string as lpDefault, ByVal lpReturnedString As Stri C, as ByVal n Size Long, _ ByVal lpFileName string) as an Ini long as the '//' control procedures INI String public function ReadIni (filename string, as the current string, string as key as) reads * 255 as the string as string dim retval, as long as V = GetPrivateProfileString (named Section, Key, "", retval, 255, file) ReadIni = Left (retval, V + 0) termination function 'A' As Ini section Folk Festival ReadIniSection (filename string section reads as string) as the stream as a String Dim rated Val ng * 255, as long as V = GetPrivateProfileSection (stream, Retval , 255, file name) ReadIniSection = Left (retval, V + 0) termination function   

I can use it to create a function that basically only section me I look in, and then within that section To find each Ini string and put it in an array and the array back so I can specify whether you want to make a loop with it?

EDIT: I think ReadIniSection returns all the things in a big string. Meaning, I need to split it up

ReadIniSection gives something that looks like this:. "Fornavn = FORNAVN [] Etternavn = ETTERNAVN" etc etc [] In the middle there is no bracket, this is a square. Probably some of the characters which are not identical, so I think that I should run it through a different command, which is assumed between a = and square.

See if it helps - split on nullchar <0:

  private all Listinisakshn Lines () dim SS string: S = Reedianiakseshn ( "c: \ windows \ win.ini", "mail") variants as dim vLines: vLines = split (S, chr $ (0 )) VLines debug vLine as variants for each vLine. Print vline Next vLine End Sub    

Comments