Use this simple VB.NET code to return the name of the month from an integer.
Example: 1 = January ….. 12 = December
Private Function GetMonthName(ByVal monthNum As Integer) As String
Try
Dim strDate As New DateTime(1, monthNum, 1)
Return strDate.ToString("MMM")
Catch ex As Exception
End Try
End Function
Use this simple VB.NET code to convert bytes to MB’s, GB’s etc. Handy for returning sizes of files/folders
Function ConvertSize(Size)
Do While InStr(Size,",") 'Remove commas from size
CommaLocate = InStr(Size,",")
Size = Mid(Size,1,CommaLocate - 1) & _
Mid(Size,CommaLocate + 1,Len(Size) - CommaLocate)
Loop</p> <p>Suffix = " Bytes"
If Size >= 1024 Then suffix = " KB"
If Size >= 1048576 Then suffix = " MB"
If Size >= 1073741824 Then suffix = " GB"
If Size >= 1099511627776 Then suffix = " TB"
Select Case Suffix
Case " KB" Size = Round(Size / 1024, 1)
Case " MB" Size = Round(Size / 1048576, 1)
Case " GB" Size = Round(Size / 1073741824, 1)
Case " TB" Size = Round(Size / 1099511627776, 1)
End Select
ConvertSize = Size & Suffix
End Function
Use this really simple VBScript to get the currently logged on user name.
Set wshNetwork = CreateObject("WScript.Network")
strUser = wshNetwork.Username
WScript.Echo "Current User: " & strUser
Use this simple script to create an internet explorer favorite link to the Microsoft MSDN library.
Const ADMINISTRATIVE_TOOLS = 6
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)
Set objFolderItem = objFolder.Self
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objFolderItem.Path
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "MSDN.url"
objURLShortcut.TargetPath = "http://msdn.microsoft.com"
objURLShortcut.Save







