Thursday, March 26, 2009

Check if Form Exists


Function formExists (db As NotesDatabase, formType As String)
Dim formTypeYes As Boolean
Forall frm In db.Forms
If Isarray (frm.Aliases) Then
If frm.Aliases (0) = formType Then
formTypeYes = True
End If
End If
End Forall
formExists = formTypeYes
End Function

Wednesday, March 25, 2009

Create Subfolder

This function first checks to see if a subfolder exists, and creates one if it does not exist. The function returns the path. It is dependent on the DirExists function.
Function CheckMakeFolder ( root As String , leaf As String) As String
Dim strPath As String
strPath = root & "\" & leaf
If Not DirExists (strPath) Then
Mkdir strPath
End If
CheckMakeFolder = strPath
End Function

New Line Symbol

The new line symbol or carriage return and linefeed symbols can be inserted using the following combination:

Chr(13) & Chr(10)

Write String to File


Sub WriteLog (strLog As String, logFileName As String )
Dim fileName As String
Dim fileNum As Integer
fileNum% = Freefile()
fileName$ = logFileName
Open FileName$ For Append As fileNum%
Write #fileNum% , strLog
Close fileNum%
End Sub

Function EndsWith


Function EndsWith (Haystack As String, Needle As String ) As Boolean

Dim lenStr As Integer
lenStr = Len(Needle)
If Mid(Haystack , Len(Haystack )-(lenStr-1)) = Needle Then
EndsWith = True
Else
EndsWith = False
End If
End Function


Usage:
Msgbox EndsWith("Stranger", "er")
Result: true

Tuesday, March 24, 2009

Remove File Extension


Function RemoveExtension (strName As String)
RemoveExtension = Left (strName, Instr(strName, ".")-1)
End Function