|
|
|
Atn2 - Arc tangent of Y/X
|
Total Hit (3365) |
«Code LangId=1»' arc tangent of Y/X - returns values in all four quadrants
Function Atn2(x As Double, y As Double) As Double
If x = 0 Then
Atn2 = Sgn(y) * 1.5707963267949
ElseIf x > 0 Then
Atn2 = Atn(y / x)
Else
Atn2 = Atn(y / x) + 3.14159265358979 * Sgn
....Read More |
Rating
|
|
|
Windows Installer Appears Every Time I Start an Application
|
Total Hit (4566) |
Intended For
Windows XP
Windows 2000
The Windows Installer is a global application used to install many Microsoft products, including Office 2000 and Office XP, and is even available to third-party developers to include with their programs.
Unfortunately, it's fraught with bugs, one of
....Read More |
Rating
|
|
|
CompareList - Compare an argument with a list of values
|
Total Hit (2367) |
«Code LangId=1»
' Return the position of the argument in a list of values
' or zero if the argument isn't included in the list
' It works for both regular values and for objects
'
' This handy function can often save you a lengthy Select Case
' statement or a complex series of If...ElseIf blo
....Read More |
Rating
|
|
|
CompareValue - Check whether a value is in a list of values
|
Total Hit (1834) |
«Code LangId=1»' Compares a numeric or string value with a list of other values.
' Returns the 1-based index of the matching value, or zero if the
' value doesn't appear in the list.
' String comparisons are case-sensitive.
'
' This function can conveniently replace a Select Case or a list
'
....Read More |
Rating
|
|
|
IsValidEmail - Validate an email address
|
Total Hit (2824) |
«Code LangId=1»' Validates an email address
' Returns True if valid, False if invalid
'
' Example:
' If IsValidEmail(Value:="x@y.com", MaxLength:=255, IsRequired:=True) then ...
Function IsValidEmail(ByRef Value As String, Optional ByVal MaxLength As Long = _
255, Optional ByVal IsRequi
....Read More |
Rating
|
|
|
IsValidSSN - Check a Social Security Number value
|
Total Hit (3085) |
«Code LangId=1»' Validates attributes of the SSN
' Returns True if valid, False if invalid
'
'Example:
' If IsValidSSN(Value:="333-44-3333", IsRequired:=True) then ...
Function IsValidSSN(ByRef Value As String, Optional ByVal IsRequired As Boolean _
= True) As Boolean
On Error
....Read More |
Rating
|
|
|
KeepInRange - Ensure that a value is in a given range
|
Total Hit (1552) |
«Code LangId=1»' Keep the first argument in the range [lowLimit, highLimit]
' If the value is adjusted, the fourth (optional) argument is set to True
'
' Note that value and limit arguments are variant, so you can use
' this routine with any type of data.
Function KeepInRange(value As Varian
....Read More |
Rating
|
|
|
NZ - Check whether a value is Null
|
Total Hit (1687) |
«Code LangId=1»' Check if a value is Null. If not it returns the value,
' otherwise it returns the ValIfNull argument, or zero/null string
' if the second argument is omitted
'
' This function is patterned after the Access function with the same name.
Public Function NZ(CheckVar As Varian
....Read More |
Rating
|
|
|
ProjectName - The name of the current project
|
Total Hit (1836) |
«Code LangId=1»' Returns the name of the current project
' The first time it's called it clears the error code
'
Function ProjectName() As String
Static result As String
If Len(result) = 0 Then
On Error Resume Next
' cause a dummy, harmless error
Err.Raise 9
....Read More |
Rating
|
|
|
|
Any2Dec - Convert from any numeric base to decimal
|
Total Hit (3234) |
«Code LangId=1»' convert from any base to decimal
' BASE can be in the range 2-36
Function Any2Dec(ByVal otherBaseNumber As String, ByVal base As Integer) As Long
Dim index As Long
Dim digits As String
Dim digitValue As Long
' check base
If base < 2 Or base > 36 T
....Read More |
Rating
|
|
|
|
Listing all available SQL Server
|
Total Hit (2171) |
Thanks to the SQL-DMO object model, it's very easy to list all the available SQL Server 7.0 installations. For example, this code loads all the SQL Servers registered on the local machine into a ComboBox control:
«Code LangId=1»
' NOTE: this code assumes that you've added a reference to the
'
....Read More |
Rating
|
|
|
Manage the SQL Server date format with SQL DMO
|
Total Hit (3071) |
If you haven't localized SQL Server for your language, the default date format is the American one: DD/MM/YY. You may need to display a date in different formats, and you can solve this problem with the help of SQL DMO. A possible solution is using the T-SQL CONVERT() function to show the date with
....Read More |
Rating
|
|
|
Programs using the WebBrowser require that IE is installed
|
Total Hit (1854) |
If your program uses the WebBrowser control or any Microsoft Internet Control, you must ensure (and clearly specify in your app's documentation) that the program can only work on systems that have Internet Explorer installed. In fact, the WebBrowser control is embedded in the ShDocVw.Dll file, which
....Read More |
Rating
|
|
|
Silent install with VB6 Deployment and Packaging Wizard
|
Total Hit (2127) |
VB6 Deployment and Packaging Wizard's resulting setup.exe has a command line switch that allows for a silent install. This feature is virtually undocumented except in the source code for Setup1.exe. The default path for the project file of Setup1 is:
C:\Program Files\Microsoft Visual Studio\VB98\
....Read More |
Rating
|
|
|
Make COM objects in a COM+ application visible to clients
|
Total Hit (1725) |
What I describe for COM+, applies to MTS with some slight differences as well.
Registering COM objects remotely has been quite a pain before MTS showed up (remember the VBR file?). In COM+ it's very easy to do:
1) Right click on the COM+ application and choose export Choose application proxy,
....Read More |
Rating
|
|
|
Misconceptions on variables and binding
|
Total Hit (1795) |
Consider this line of code:
Dim x as Project1.Class1
Many developers think that we were declaring x as a "Project1.Class1" object. This is wrong. All object variables in VB are interface variables. In this line of code x is declared as the _Class1 interface defined in the Project1 Type librar
....Read More |
Rating
|
|
|
Never use New to create MTS/COM+ objects
|
Total Hit (1807) |
A common question among VB developers is: Why is it dangerous the use of the New keyword in VB to create COM objects registered under MTS/COM+?
The New keyword is the only way to go when you want to create objects that are defined as PublicNotCreatable or Private (CreateObject doesn't work) insid
....Read More |
Rating
|
|
|
Reduce COM+ context overhead: use non configured classes
|
Total Hit (1588) |
In another item in this Tip Bank (see link below), we mention that you can co-locate secondary instances within the context of the caller. If you don't need any services at all for your secondary components, then you don't have to configure them as COM+ components either. You lose the deployment and
....Read More |
Rating
|
|
|
Reduce context overhead for COM+ components
|
Total Hit (1460) |
Instances of configured components, that is, components configured in COM+, get runtime services owing to context objects. When you instantiate a COM+ component, your instance will live in a context object. When you call a method of your instance, the call will go through the context and that is whe
....Read More |
Rating
|
|
|
Replicate a complete COM+ catalog to another machine
|
Total Hit (1786) |
The Component Services MMC gives you an easy way to export and import COM+ applications. However, if you want to export the entire COM+ catalog to one or more systems on your LAN you can do it quickly with the COMREPL command-line utility, which you can find in the c:\windows\system32\com directory.
....Read More |
Rating
|
|
|
Setting authentication across different domains
|
Total Hit (1423) |
COM doesn't have a built in security mechanism, but relies on Windows authentication services (Security Service Providers). When you access a resource or invoke a method in a remote DCOM server (or MTS package / COM+ Application), security checks cannot be performed in the standard way if the client
....Read More |
Rating
|
|
|
The best setting for the RunAs option in a server package
|
Total Hit (1715) |
When you deploy COM objects in DLLs no security issues arise since DLLs run in the process of the caller. On the contrary, when you deploy your COM objects into an .EXE, you have to deal with such issues.
- (D)COM needs to know under what security principal (read identity) the process, where you
....Read More |
Rating
|
|
|
Tips for debugging MTS components in the VB IDE
|
Total Hit (1545) |
It was and it is still easy to debug MTS components written on Visual C++ version 5 and higher. Debugging components written on Visual Basic 5 is possible under VC IDE. Starting with version 6, Visual Basic allows to debug under its own IDE. Here are the things you should keep in mind while preparin
....Read More |
Rating
|
|
|
Setting authentication across different domains
|
Total Hit (1621) |
COM doesn't have a built in security mechanism, but relies on Windows authentication services (Security Service Providers). When you access a resource or invoke a method in a remote DCOM server (or MTS package / COM+ Application), security checks cannot be performed in the standard way if the client
....Read More |
Rating
|
|
|
Be careful when installing SHLWAPI.DLL with Visual Installer
|
Total Hit (1888) |
I happened to come across a serious problem when installing my own software with Visual Installer 1.1: the installation of my product on Windows 98 computers caused a system crash during the next Windows start-up. The only way to fix things was to reinstall Windows from CD, over the existent version
....Read More |
Rating
|
|
|
Out-of-date dependency file for COMCTL32.OCX
|
Total Hit (2087) |
Have you ever read a message like "Dependency file for COMCTL32.OCX is out of date" during the package creation process? The cause of this problem is simple: you have installed an application that has replaced your COMCTL32.OCX ActiveX with the newer release (which is 5.00.3828 at this time). The Ac
....Read More |
Rating
|
|