home *** CD-ROM | disk | FTP | other *** search
Wrap
Attribute VB_Name = "General" Option Explicit Public IniPath As String '********** OUTSIDE FUNCTIONS ***********' Declare Function writeprivateprofilestring Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyname As Any, ByVal lpString As String, ByVal lpfilename As String) As Long Declare Function getprivateprofilestring Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyname As Any, ByVal lpdefault As String, ByVal lpreturnedstring As String, ByVal nsize As Long, ByVal lpfilename As String) As Long Public Function ReadField(Pos As Integer, Text As String, SepASCII As Integer) As String '***************************************************************** 'Gets a field from a string '***************************************************************** Dim i As Integer Dim LastPos As Integer Dim CurChar As String * 1 Dim FieldNum As Integer Dim Seperator As String Seperator = Chr(SepASCII) LastPos = 0 FieldNum = 0 For i = 1 To Len(Text) CurChar = Mid(Text, i, 1) If CurChar = Seperator Then FieldNum = FieldNum + 1 If FieldNum = Pos Then ReadField = Mid(Text, LastPos + 1, (InStr(LastPos + 1, Text, Seperator, vbTextCompare) - 1) - (LastPos)) Exit Function End If LastPos = i End If Next i FieldNum = FieldNum + 1 If FieldNum = Pos Then ReadField = Mid(Text, LastPos + 1) End If End Function Function FileExist(File As String, FileType As VbFileAttribute) As Boolean '***************************************************************** 'Checks to see if a file exists '***************************************************************** If Dir(File, FileType) = "" Then FileExist = False Else FileExist = True End If End Function Function GetVar(File As String, Main As String, Var As String) As String '***************************************************************** 'Get a variable from a a text file '***************************************************************** Dim l As Integer Dim Char As String Dim sSpaces As String ' This will hold the input that the program will retrieve Dim szReturn As String ' This will be the defaul value if the string is not found szReturn = "" sSpaces = Space(5000) ' This tells the computer how long the longest string can be. If you want, you can change the number 75 to any number you wish getprivateprofilestring Main, Var, szReturn, sSpaces, Len(sSpaces), File GetVar = RTrim(sSpaces) GetVar = Left(GetVar, Len(GetVar) - 1) End Function