Menjadikan huruf awal menjadi huruf besar

Public Function FirstUCaseWord(ByVal MyString As String) As String

Dim PosSpc As Integer

Mid(MyString, 1, 1) = UCase(Mid(MyString, 1, 1))

PosSpc = InStr(MyString, ” “)

While PosSpc <> 0

Mid(MyString, PosSpc + 1, 1) = UCase(Mid(MyString, PosSpc + 1, 1))

PosSpc = InStr(PosSpc + 1, MyString, ” “)

Wend

FirstUCaseWord = MyString

End Function

Nilai tanggal awal dari bulan

Public Function FirstOfMonth(ByVal xDate As Date) As Date

FirstOfMonth = DateSerial(Year(xDate), Month(xDate), 1)

End Function

Nilai tanggal akhir dari satu bulan

Public Function EndOfMonth(ByVal xDate As Date) As Date

EndOfMonth = DateSerial(Year(xDate), Month(xDate) + 1, 0)

End Function

Nilai tanggal akhir dari satu minggu

Public Function EndOfWeek(ByVal xDate As Date) As Date

EndOfWeek = xDate – Weekday(xDate) + 7

End Function

Mendapatkan Nama user pada Operasi Windows

Mendapatkan Nama user pada Operasi Windows

‘— Letakkan di module

Public Declare Function GetUserNameA Lib “advapi32.dll” _

(ByVal lpBuffer As String, nSize As Long) As Long

‘— Akhir Letakkan di module

Public Function GetUserName() As String

Dim UserName As String * 255

Call GetUserNameA(UserName, 255)

GetUserName = Left$(UserName, InStr(UserName, Chr$(0)) – 1)

End Function

Private Sub Form_Load()

MsgBox GetUserName

End Sub

Mendapatkan Nilai dari Resolusi Windows

Mendapatkan Nilai dari Resolusi Windows

Public Function GetWinScrResolution() As String

Dim intWidth As Integer

Dim intHeight As Integer

intWidth = Screen.Width \ Screen.TwipsPerPixelX

intHeight = Screen.Height \ Screen.TwipsPerPixelY

GetWinScrResolution = Str$(intWidth) + ” x” + Str$(intHeight)

End Function

Private Sub Form_Load()

MsgBox GetWinScrResolution

End Sub

Mendapatkan Posisi direktory system Windows

Fungsi untuk Mendapatkan Posisi direktory system Windows

‘— Letakkan di module

Declare Function GetSystemDirectory Lib “kernel32” Alias “GetSystemDirectoryA” _

(ByVal lpBuffer As String, ByVal nSize As Long) As Long

‘— Akhir Letakkan di module

Public Function GetSysDir() As String

Dim boolRetVal As Boolean, lpBuffer As String, nSize As Long

lpBuffer = Space(255): nSize = 254

boolRetVal = GetSystemDirectory(lpBuffer, nSize)

GetSysDir = StripNullTerminator(lpBuffer)

End Function

Function StripNullTerminator(lpBuffer As String) As String

Dim I As Integer

For I = 1 To 255

If Asc(Mid(lpBuffer, I, 1)) = 0 Then

lpBuffer = Left(lpBuffer, I – 1)

Exit For

End If

Next I

StripNullTerminator = lpBuffer

End Function

Private Sub Form_Load()

MsgBox GetSysDir

End Sub