To copy this code, simply highlight the area you want and paste it into your form. Although it looks strange, it does work - TRUST ME.
Easy fax: (My own program that lets you send faxes simply: Not tested)
To a blank form add a textbox called Text1, a Command button called cmdCopy, another called cmdDial and a MSComm object and add the following code:
Option Explicit
Private Sub cmdDial_Click()
Clipboard.GetText
Let Text = comOne
Dim A$
A$ = txtDial
If A$ = "" Then
MsgBox "Mark and copy a number first."
Exit Sub
End If
comOne.CommPort = 1
comOne.Settings = "9600,N,8,1"
comOne.PortOpen = True
comOne.Output = "ATDT" & A$ & vbCr
MsgBox "Dialing " & A$ & vbCrLf &
"Pick up the phone...", _
vbOKOnly, "Dial-A-Phone"
comOne.PortOpen = True
End Sub
Private Sub cmdCopy_Click()
Clipboard.Clear ' Clear Clipboard.
Clipboard.SetText Text1.Text ' Put text on Clipboard.
End Sub
Clip-Clearer: (My own program that allows the clip-board's contents to be cleared.)
To a blank form, add a Command button called cmdClear and an explanation label, and add this code:
Option Explicit
Private Sub Form_KeyPress(KeyAscii As Integer)
Unload Me
End Sub
Private Sub Form_Load()
lblVersion.Caption = "Version " & App.Major &
"." & App.Minor & "." &
App.Revision
lblProductName.Caption = App.Title
End Sub
Designer clock: (My own program that lets you take any BMP picture, and add it to the back-round of the clock. For tis you need 4 forms: An about form called frmAbout, a splash screen called frmSplash, and two normal forms: 1 named frmClock and the other named frmClock2. You will then need: A picture box called picBackGround on frmClock, a timer named tmrClock and set to an interval of 100. On frmClock2, add a Command button called cmdOk, another called cmdCancel, a picture box called picHourColor, another called picMinuteColor and lastly, another named picMinuteColor. Then add the following code:
frmAbout
Option Explicit
' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
' Reg Key ROOT Types...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1 ' Unicode nul terminated string
Const REG_DWORD = 4 ' 32-bit number
Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools
Location"
Const gREGVALSYSINFOLOC = "MSINFO"
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared
Tools\MSINFO"
Const gREGVALSYSINFO = "PATH"
Private Declare Function RegOpenKeyEx Lib "advapi32"
Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal
lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As
Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32"
Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal
lpValueName As String, ByVal lpReserved As Long, ByRef lpType As
Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32"
(ByVal hKey As Long) As Long
Private Sub cmdSysInfo_Click()
Call StartSysInfo
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Caption = "About " & App.Title
lblVersion.Caption = "Version " & App.Major &
"." & App.Minor & "." &
App.Revision
lblTitle.Caption = App.Title
End Sub
Public Sub StartSysInfo()
On Error GoTo SysInfoErr
Dim rc As Long
Dim SysInfoPath As String
' Try To Get System Info Program Path\Name From Registry...
If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO,
gREGVALSYSINFO, SysInfoPath) Then
' Try To Get System Info Program Path Only From Registry...
ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC,
gREGVALSYSINFOLOC, SysInfoPath) Then
' Validate Existance Of Known 32 Bit File Version
If (Dir(SysInfoPath & "\MSINFO32.EXE") <>
"") Then
SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
' Error - File Can Not Be Found...
Else
GoTo SysInfoErr
End If
' Error - Registry Entry Can Not Be Found...
Else
GoTo SysInfoErr
End If
Call Shell(SysInfoPath, vbNormalFocus)
Exit Sub
SysInfoErr:
MsgBox "System Information Is Unavailable At This
Time", vbOKOnly
End Sub
Public Function GetKeyValue(KeyRoot As Long, KeyName As String,
SubKeyRef As String, ByRef KeyVal As String) As Boolean
Dim i As Long ' Loop Counter
Dim rc As Long ' Return Code
Dim hKey As Long ' Handle To An Open Registry Key
Dim hDepth As Long '
Dim KeyValType As Long ' Data Type Of A Registry Key
Dim tmpVal As String ' Tempory Storage For A Registry Key Value
Dim KeyValSize As Long ' Size Of Registry Key Variable
'------------------------------------------------------------
' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
'------------------------------------------------------------
rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) '
Open Registry Key
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle
Error...
tmpVal = String$(1024, 0) ' Allocate Variable Space
KeyValSize = 1024 ' Mark Variable Size
'------------------------------------------------------------
' Retrieve Registry Key Value...
'------------------------------------------------------------
rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle
Errors
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null
Terminated String...
tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From
String
Else ' WinNT Does NOT Null Terminate String...
tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract
String Only
End If
'------------------------------------------------------------
' Determine Key Value Type For Conversion...
'------------------------------------------------------------
Select Case KeyValType ' Search Data Types...
Case REG_SZ ' String Registry Key Data Type
KeyVal = tmpVal ' Copy String Value
Case REG_DWORD ' Double Word Registry Key Data Type
For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char.
By Char.
Next
KeyVal = Format$("&h" + KeyVal) ' Convert Double
Word To String
End Select
GetKeyValue = True ' Return Success
rc = RegCloseKey(hKey) ' Close Registry Key
Exit Function ' Exit
GetKeyError: ' Cleanup After An Error Has Occured...
KeyVal = "" ' Set Return Val To Empty String
GetKeyValue = False ' Return Failure
rc = RegCloseKey(hKey) ' Close Registry Key
End Function
frmClock
Option Explicit
Public gnHourHandColor As Integer
Public gnMinuteHandColor As Integer
Public gnSecondHandColor As Integer
Private mnHnum As Integer
Private mnMnum As Integer
Private mnSnum As Integer
Private mlHcolor As Long
Private mlMcolor As Long
Private mlScolor As Long
Private mfHlen As Single
Private mfMlen As Single
Private mfSlen As Single
Private msAppname As String
Private msSection As String
Private msKey As String
Private msSetting As String
Private Const Pi = 3.14159265358979
Private Const TwoPi = Pi + Pi
Private Const HalfPi = Pi / 2
Private Sub Form_Load()
'Fill form exactly with background image
picBackGround.Move 0, 0
Width = picBackGround.Width + (Width - ScaleWidth)
Height = picBackGround.Height + (Height - ScaleHeight)
'Change the scaling of the clock face
picBackGround.Scale (-2, -2)-(2, 2)
'Center form
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
'Set width of hands in pixels
picBackGround.DrawWidth = 5
'Set length of hands
mfHlen = 0.8
mfMlen = 1.5
mfSlen = 1
'Set colors of hands from Registry settings
msAppname = "VBClock"
msSection = "Hands"
msKey = "mlHcolor"
msSetting = GetSetting(msAppname, msSection, msKey)
gnHourHandColor = Val(msSetting)
msKey = "mlMcolor"
msSetting = GetSetting(msAppname, msSection, msKey)
gnMinuteHandColor = Val(msSetting)
msKey = "mlScolor"
msSetting = GetSetting(msAppname, msSection, msKey)
gnSecondHandColor = Val(msSetting)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Save current hand colors
msKey = "mlHcolor"
msSetting = Str$(gnHourHandColor)
SaveSetting msAppname, msSection, msKey, msSetting
msKey = "mlMcolor"
msSetting = Str$(gnMinuteHandColor)
SaveSetting msAppname, msSection, msKey, msSetting
msKey = "mlScolor"
msSetting = Str$(gnSecondHandColor)
SaveSetting msAppname, msSection, msKey, msSetting
End Sub
Private Sub mnuAbout_Click()
frmAbout.Show vbModal
End Sub
Private Sub Sound()
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub mnuContents_Click()
MsgBox "Please access help files from disk"
End Sub
Private Sub mnuHandColors_Click()
frmVBClock2.Show vbModal
End Sub
Private Sub mnuSearch_Click()
MsgBox "Please access help files from disk"
End Sub
Private Sub picBackGround_Click()
End Sub
Private Sub tmrClock_Timer()
Dim dHang As Double
Dim dMang As Double
Dim dSang As Double
Dim dHx As Double
Dim dHy As Double
Dim dMx As Double
Dim dMy As Double
Dim dSx As Double
Dim dSy As Double
'Keep track of current second
Static LastSecond
'Check to see if new second
If Second(Now) = LastSecond Then
Exit Sub
Else
LastSecond = Second(Now)
End If
'Update time variables
mnHnum = Hour(Now)
mnMnum = Minute(Now)
mnSnum = Second(Now)
'Calculate hand angles
dHang = TwoPi * (mnHnum + mnMnum / 60) / 12 - HalfPi
dMang = TwoPi * (mnMnum + mnSnum / 60) / 60 - HalfPi
dSang = TwoPi * mnSnum / 60 - HalfPi
'Calculate endpoints for each hand
dHx = mfHlen * Cos(dHang)
dHy = mfHlen * Sin(dHang)
dMx = mfMlen * Cos(dMang)
dMy = mfMlen * Sin(dMang)
dSx = mfSlen * Cos(dSang)
dSy = mfSlen * Sin(dSang)
'Restore background image
picBackGround.Cls
'Draw new hands
picBackGround.Line (0, 0)-(dMx, dMy), QBColor(gnMinuteHandColor)
picBackGround.Line (0, 0)-(dHx, dHy), QBColor(gnHourHandColor)
picBackGround.Line (0, 0)-(dSx, dSy), QBColor(gnSecondHandColor)
End Sub
Private Sub mnuSetTime_Click()
Dim sPrompt As String
Dim sTitle As String
Dim sDefault As String
Dim sStartTime As String
Dim sTim As String
Dim sMsg As String
'Ask user for new time
sPrompt = "Enter the time, using the format 00:00:00"
sTitle = "Martin's Clock"
sDefault = Time$
sStartTime = sDefault
sTim = InputBox$(sPrompt, sTitle, sDefault)
'Check if user clicked Cancel
'or clicked OK with no change to time
If sTim = "" Or sTim = sStartTime Then
Exit Sub
End If
'Set new time
On Error GoTo ErrorTrap
Time$ = sTim
Exit Sub
ErrorTrap:
sMsg = "The time you entered is invalid. " + sTim
MsgBox sMsg, 48, "VBClock"
Resume Next
End Sub
frmClock2
Option Explicit
Public gnHourHandColor As Integer
Public gnMinuteHandColor As Integer
Public gnSecondHandColor As Integer
Private mnHnum As Integer
Private mnMnum As Integer
Private mnSnum As Integer
Private mlHcolor As Long
Private mlMcolor As Long
Private mlScolor As Long
Private mfHlen As Single
Private mfMlen As Single
Private mfSlen As Single
Private msAppname As String
Private msSection As String
Private msKey As String
Private msSetting As String
Private Const Pi = 3.14159265358979
Private Const TwoPi = Pi + Pi
Private Const HalfPi = Pi / 2
Private Sub Form_Load()
'Fill form exactly with background image
picBackGround.Move 0, 0
Width = picBackGround.Width + (Width - ScaleWidth)
Height = picBackGround.Height + (Height - ScaleHeight)
'Change the scaling of the clock face
picBackGround.Scale (-2, -2)-(2, 2)
'Center form
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
'Set width of hands in pixels
picBackGround.DrawWidth = 5
'Set length of hands
mfHlen = 0.8
mfMlen = 1.5
mfSlen = 1
'Set colors of hands from Registry settings
msAppname = "VBClock"
msSection = "Hands"
msKey = "mlHcolor"
msSetting = GetSetting(msAppname, msSection, msKey)
gnHourHandColor = Val(msSetting)
msKey = "mlMcolor"
msSetting = GetSetting(msAppname, msSection, msKey)
gnMinuteHandColor = Val(msSetting)
msKey = "mlScolor"
msSetting = GetSetting(msAppname, msSection, msKey)
gnSecondHandColor = Val(msSetting)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Save current hand colors
msKey = "mlHcolor"
msSetting = Str$(gnHourHandColor)
SaveSetting msAppname, msSection, msKey, msSetting
msKey = "mlMcolor"
msSetting = Str$(gnMinuteHandColor)
SaveSetting msAppname, msSection, msKey, msSetting
msKey = "mlScolor"
msSetting = Str$(gnSecondHandColor)
SaveSetting msAppname, msSection, msKey, msSetting
End Sub
Private Sub mnuAbout_Click()
frmAbout.Show vbModal
End Sub
Private Sub Sound()
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub mnuContents_Click()
MsgBox "Please access help files from disk"
End Sub
Private Sub mnuHandColors_Click()
frmVBClock2.Show vbModal
End Sub
Private Sub mnuSearch_Click()
MsgBox "Please access help files from disk"
End Sub
Private Sub picBackGround_Click()
End Sub
Private Sub tmrClock_Timer()
Dim dHang As Double
Dim dMang As Double
Dim dSang As Double
Dim dHx As Double
Dim dHy As Double
Dim dMx As Double
Dim dMy As Double
Dim dSx As Double
Dim dSy As Double
'Keep track of current second
Static LastSecond
'Check to see if new second
If Second(Now) = LastSecond Then
Exit Sub
Else
LastSecond = Second(Now)
End If
'Update time variables
mnHnum = Hour(Now)
mnMnum = Minute(Now)
mnSnum = Second(Now)
'Calculate hand angles
dHang = TwoPi * (mnHnum + mnMnum / 60) / 12 - HalfPi
dMang = TwoPi * (mnMnum + mnSnum / 60) / 60 - HalfPi
dSang = TwoPi * mnSnum / 60 - HalfPi
'Calculate endpoints for each hand
dHx = mfHlen * Cos(dHang)
dHy = mfHlen * Sin(dHang)
dMx = mfMlen * Cos(dMang)
dMy = mfMlen * Sin(dMang)
dSx = mfSlen * Cos(dSang)
dSy = mfSlen * Sin(dSang)
'Restore background image
picBackGround.Cls
'Draw new hands
picBackGround.Line (0, 0)-(dMx, dMy), QBColor(gnMinuteHandColor)
picBackGround.Line (0, 0)-(dHx, dHy), QBColor(gnHourHandColor)
picBackGround.Line (0, 0)-(dSx, dSy), QBColor(gnSecondHandColor)
End Sub
Private Sub mnuSetTime_Click()
Dim sPrompt As String
Dim sTitle As String
Dim sDefault As String
Dim sStartTime As String
Dim sTim As String
Dim sMsg As String
'Ask user for new time
sPrompt = "Enter the time, using the format 00:00:00"
sTitle = "Martin's Clock"
sDefault = Time$
sStartTime = sDefault
sTim = InputBox$(sPrompt, sTitle, sDefault)
'Check if user clicked Cancel
'or clicked OK with no change to time
If sTim = "" Or sTim = sStartTime Then
Exit Sub
End If
'Set new time
On Error GoTo ErrorTrap
Time$ = sTim
Exit Sub
ErrorTrap:
sMsg = "The time you entered is invalid. " + sTim
MsgBox sMsg, 48, "VBClock"
Resume Next
End Sub
frmSplash
Option Explicit
Private Sub Form_KeyPress(KeyAscii As Integer)
Unload Me
End Sub
Private Sub Form_Load()
lblVersion.Caption = "Version " & App.Major &
"." & App.Minor & "." &
App.Revision
lblProductName.Caption = App.Title
End Sub
(Joke) Square-edit:
Not what you may think. It, when
loaded, tells the victim that they have a virus and gives them
the option to delete all files or close. Of course, the Close
doesn't work...
You need two forms four command buttons (don't name them at all)
and two lables - one on Form1: Install Square-edit for windows
95? then under that the buttons. On form2: Fatal virus (Location
OE110000000) and then add this code:
Form1:
Private Sub Command1_Click()
Form2.Show
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Form2:
Private Sub Command1_Click()
Unload Me
MsgBox "He-he!!! What a Joke!!!", vbExclamation
End Sub
Private Sub Command2_Click()
MsgBox "This function is not available", vbCritical
End Sub
(You may have to add some alterations to this code.)
If that looks like too much hard work, then e-mail me for the compiled version.
This is only the first few
sample programs to appear here. Within a couple of weeks, there
should be many more. If you don't have VB 5, e-mail me for them
and I will
send them via e-mail in a nice posh little install package.
Penatgon +: A multy purpose tool.