Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.
‘ Converts a time value to a numeric value in seconds’ Example:’ MsgBox TimeToSeconds(TimeSerial(3, 5, 20)) –> 11120Function TimeToSeconds(ByVal newTime As Date) As Long TimeToSeconds = Hour(newTime) * 3600 +
Enum DateTimeFormat dtGeneralDate dtLongDate dtMediumDate dtShortDate dtLongTime dtMediumTime dtShortTime dtCustomEnd Enum’ Enhanced VB FormatDateTime functionFunction FormatDateTimeEx(newDate, Optional ByVal dtFormat As DateTimeFormat = _ dtGeneralDate, Optional FirstDayOfWeek As VbDayOfWeek = vbSunday,
‘ Converts a numeric value in seconds to a string’ Example:’ MsgBox SecondsToString(3920) –> 1h.5m.20sFunction SecondsToString(ByVal Seconds As Long) As String SecondsToString = (Seconds 3600) & “h.” & ((Seconds 60)
‘ Converts a time value to a numeric value in minutes’ Example:’ MsgBox TimeToMinutes(TimeSerial(3, 5, 0)) –> 185Function TimeToMinutes(ByVal newTime As Date) As Long TimeToMinutes = Hour(newTime) * 60 +
‘ Converts a numeric value in seconds to a time value’ Example:’ MsgBox SecondsToTime(11120) –> 3.5.20 AMFunction SecondsToTime(ByVal Seconds As Long) As Date SecondsToTime = CDate(Seconds / 86400) End Function
Private Declare Function GetSystemPowerStatus Lib “kernel32” _ (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As LongPrivate Type SYSTEM_POWER_STATUS ACLineStatus As Byte BatteryFlag As Byte BatteryLifePercent As Byte Reserved1 As Byte BatteryLifeTime As Long BatteryFullLifeTime
The RegExp object in the Microsoft VBScript Regular Expression type library supports regular expression patterns containing the | (or) operator, which lets you search for multiple substrings at the same
Most of you might have worked withInternet Transfer Control which is very handy control when it comes to InternetProgramming but there is another control which even more robust and helpsprogrammers
‘ Set the IE start page’ Note: requires the SetRegistryValue, CheckRegistryKey and CreateRegistryKey ‘ routines, you can find them in the CodeBank’ Example:’ SetIEStartPage “http://www.vb2themax.com”Public Sub SetIEStartPage(ByVal sPage As String)
‘ Applies URL encoding rules to the specified Text and returns the result’ (similar to Server.URLEncode)Public Function URLEncodeEx(ByVal Text As String) As String Dim abytTokens() As Byte Dim lngTotal As
‘ Decodes URL encoding applied to the specified Text and returns the resultPublic Function URLDecodeEx(ByVal Text As String) As String Dim abytTokens() As Byte Dim lngTotal As Long Dim lngCount
‘ Applies HTML encoding rules to the specified Text and returns the result” Optionally specify if we’re encoding a HREF link and the character’ to use for encoding – the
‘ Get the IE start page’ Note: requires the GetRegistryValue routine, you can find it in the CodeBank’ Example:’ MsgBox GetIEStartPagePublic Function GetIEStartPage() As String Const HKEY_CURRENT_USER = &H80000001 GetIEStartPage
‘ Decodes HTML encoding applied to the specified Text and returns the result’ Optionally specify if we encoded a HREF link and the character’ used for encoding – the default
In many cases you may need the canonical (or absolute) name of a file, for example when you need to compare two relative file names (relative to the current directory
ugust 8, 2001?If one envisions Sun Microsystems and Microsoft as, oh, I don’t know, peevish comic book villains, each sticking dogmatically by their own proprietary weaponry in the fight for
Servlets often need to display a lot of HTML. One way to do this is with println() commands and String concatenation. However, String concatenation is an expensive process. It is
There are times when almost every programmer comes up with a class that consists only of public static methods. Usually these are some kind of utility classes, which do not
There is a constructor in the java.io.FileOutputStream class which can be used to append data to an existing file. Usage:public FileOutputStream(String name, boolean append) throwsFileNotFoundExceptionwhere:name – the file nameappend –
To access a file that is kept in the same directory as the servlet, you can do either of the following things:1. Hard-coding the file path: FileReader fr = new
‘ API declaration’Private Declare Function GetForegroundWindow Lib
Unregister Mswcrun.dll version 6.00.8450 by running the following command from the run dialog box: regsvr32.exe /u
Create a VB standard exe project and paste the following code in your form’s code window: Option ExplicitPrivate Declare Function ShellExecute Lib
Here’s a very short bit of code that will make a StatusBar hide or show, accordingly: public void viewStatusBar() { /* Hide or show the statusbar */ StatusBarPane().setVisible(!(StatusBarPane().isVisible()));} Just have
Objects frequently contain member objects that need to be exposed.Often, these are not correctly encapsulated, which could lead to problems that are difficult to track down.Consider a Circus object, which
Start a new VB project. Add a form (or use the default one). Then, add these four buttons on the form: create (cmdCreateFile), read (cmdRead), append (cmdAppend), and delete (cmdDelete).
Most coding standards recommend the use of Hungarian variable naming, which uses prefixes to indicate the variable’s type. However, these naming conventions usually should not be used in a component’s
This tip is useful if you do Outlook automation with user created Outlook folders. These folders cannot be accessed by the GetDefaultFolder method usually employed in automation techniques. This snippet
This handy add-in creates code headers in VB source and HTML documentation for VB projects. When you run HTML Doc the first time, it will create all these headers with
Why should you createAdd-Ins? We programmers always feel that we are short of several features whileworking with Microsoft tools, it seems that Microsoft hasn’t yet developed thetool we needed. In











