home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
vb_code2
/
str_plus
/
strplus.bas
< prev
next >
Wrap
BASIC Source File
|
1994-07-19
|
11KB
|
334 lines
'StrPlus.DLL should be in your Windows\System directory or in the Path
'Assorted StrPlus Functions
Declare Function GetStrPlusVersion% Lib "StrPlus.DLL" ()
Declare Function GetStateOfKey% Lib "StrPlus.DLL" (ByVal KeyName$)
'KeyName$=ScrollLock,NumLock,CapsLock,Rshift,Lshift,Control, or Alt
'StrPlus General String Functions
Declare Sub ReverseString Lib "StrPlus.DLL" (ByVal lpString$)
Declare Sub ToName Lib "StrPlus.DLL" (ByVal lpString$)
'end of lpString$ is assumed at chr$(0) or chr$(13)
Declare Sub GetToken Lib "StrPlus.DLL" (ByVal lpString$, ByVal lpDelimiters$, ByVal TokenNumber%, ByVal lpReturn$)
Declare Function GetTokenCount% Lib "StrPlus.DLL" (ByVal lpString$, ByVal lpDelimiters$)
Declare Sub Encrypt Lib "StrPlus.DLL" (ByVal lpString$, ByVal KeyCode%)
Declare Sub Decrypt Lib "StrPlus.DLL" (ByVal lpString$, ByVal KeyCode%)
Declare Function CountWords% Lib "StrPlus.DLL" (ByVal lpString$)
'end of lpString$ is assumed at chr$(0) or chr$(13)
Declare Sub GetOrdinalExt Lib "StrPlus.DLL" (ByVal TheNumber%, ByVal lpReturnString$)
Declare Sub GetRomanNumber Lib "StrPlus.DLL" (ByVal TheNumber%, ByVal lpReturnString$)
Declare Sub GetWordNumber Lib "StrPlus.DLL" (ByVal lpAmount$, ByVal lpReturnString$)
Declare Function WordColor& Lib "StrPlus.DLL" (ByVal ColorWord$)
'Basic Color Words
'Black
'Blue
'Green
'Cyan
'Red
'Magenta
'DarkYellow
'LightGray
'DarkGray
'BrightBlue
'BrightGreen
'BrightCyan
'BrightRed
'BrightMagenta
'BrightYellow
'BrightWhite
'System Color Words
'ActiveBorder
'ActiveCaption
'AppWorkSpace
'BackGround
'BtnFace
'BtnHighlight
'BtnShadow
'BtnText
'CaptionText
'GrayText
'Highlight
'HighlightText
'InactiveBorder
'InactiveCaption
'InactiveCaptionText
'Menu
'MenuText
'Window
'WindowFrame
'WindowText
'StrPlus File String Functions
Declare Sub ExtFromPath Lib "StrPlus.DLL" (ByVal lpFullPath$, ByVal lpString$)
Declare Sub FileNameOnlyFromPath Lib "StrPlus.DLL" (ByVal lpFullPath$, ByVal lpString$)
Declare Sub FullFileNameFromPath Lib "StrPlus.DLL" (ByVal lpFullPath$, ByVal lpString$)
Declare Sub DirFromPath Lib "StrPlus.DLL" (ByVal lpFullPath$, ByVal lpString$)
Declare Sub DriveFromPath Lib "StrPlus.DLL" (ByVal lpFullPath$, ByVal lpString$)
'StrPlus String Output Functions
Declare Sub JustifyLine Lib "StrPlus.DLL" (ByVal hDC%, ByVal StartXpixel%, ByVal StartYpixel%, ByVal TheWidthPixels%, ByVal lpString$)
Declare Sub SuperPrint Lib "StrPlus.DLL" (ByVal hDC%, ByVal XstartPixel%, ByVal YstartPixel%, ByVal TheString$, ByVal FontName$, ByVal TheStyle$, ByVal The3DStyle$, ByVal AlignmentType$, ByVal PointSize%, ByVal TheColor&, ByVal ShadowColor&, ByVal RotationAngle%)
'TheStyle$=bold, italic, BoldItalic, or plain
'The3Dstyle$=raised, sunken, or plain
'AlignmentType$=left, right, or center
'RototationAngle= 0- 359
'Assorted Win API Functions
Declare Function DestroyWindow% Lib "User" (ByVal hWnd%)
Declare Function GetWindowsDirectory% Lib "Kernel" (ByVal lpBuffer$, ByVal nSize%)
Declare Function OutMessage% Lib "User" Alias "SendMessage" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, lParam As Any)
Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, lParam As Any)
Declare Function WinHelp% Lib "User" (ByVal hWnd%, ByVal lpHelpFile$, ByVal wCommand%, ByVal dwData As Any)
Global Const HELP_CONTENTS = &H3
Global Const HELP_PARTIALKEY = &H105
'program constants
Global Const raised = 1
Global Const sunken = 2
'program variables
Global FormPassString As String 'used to pass strings
Global FormPassString2 As String
Function AddSeparator (ThePath$)
If Right$(ThePath$, 1) <> "\" Then
ThePath$ = ThePath$ + "\"
End If
AddSeparator = ThePath$
End Function
Sub DoControl3D (Obj As Control, Style%, Thick%)
If Thick <= 0 Then Thick = 1
If Thick > 8 Then Thick = 8
OldMode = Obj.Parent.ScaleMode
OldWidth = Obj.Parent.DrawWidth
Obj.Parent.ScaleMode = 3
Obj.Parent.DrawWidth = 1
ObjHeight = Obj.Height
ObjWidth = Obj.Width
ObjLeft = Obj.Left
ObjTop = Obj.Top
Select Case Style
Case sunken:
TLshade = QBColor(8)
BRshade = QBColor(15)
Case raised:
TLshade = QBColor(15)
BRshade = QBColor(8)
End Select
For i = 1 To Thick
CurLeft = ObjLeft - i
CurTop = ObjTop - i
CurWide = ObjWidth + (i * 2) - 1
CurHigh = ObjHeight + (i * 2) - 1
Obj.Parent.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
Obj.Parent.Line -Step(0, CurHigh), BRshade
Obj.Parent.Line -Step(-CurWide, 0), BRshade
Obj.Parent.Line -Step(0, -CurHigh), TLshade
Next i
If Thick > 2 Then
CurLeft = ObjLeft - Thick - 1
CurTop = ObjTop - Thick - 1
CurWide = ObjWidth + ((Thick + 1) * 2) - 1
CurHigh = ObjHeight + ((Thick + 1) * 2) - 1
Obj.Parent.Line (CurLeft, CurTop)-Step(CurWide, 0), QBColor(0)
Obj.Parent.Line -Step(0, CurHigh), QBColor(0)
Obj.Parent.Line -Step(-CurWide, 0), QBColor(0)
Obj.Parent.Line -Step(0, -CurHigh), QBColor(0)
End If
Obj.Parent.ScaleMode = OldMode
Obj.Parent.DrawWidth = OldWidth
End Sub
Sub DoForm3D (TheForm As Form, Style%, Thick%, Distance%)
If Thick <= 0 Then Thick = 1
If Thick > 8 Then Thick = 8
If Distance < 0 Then Distance = 0
If Distance > 8 Then Distance = 8
OldMode = TheForm.ScaleMode
OldWidth = TheForm.DrawWidth
TheForm.ScaleMode = 3
TheForm.DrawWidth = 1
FormHeight = TheForm.ScaleHeight
FormWidth = TheForm.ScaleWidth
FormLeft = TheForm.ScaleLeft
FormTop = TheForm.ScaleTop
Select Case Style
Case sunken:
TLshade = QBColor(8)
BRshade = QBColor(15)
Case raised:
TLshade = QBColor(15)
BRshade = QBColor(8)
End Select
Select Case TheForm.BorderStyle
Case 0:
OLshade = QBColor(0)
TheForm.Line (0, 0)-(FormWidth, 0), OLshade
TheForm.Line (0, 0)-(0, FormHeight), OLshade
TheForm.Line (FormWidth - 1, 0)-(FormWidth - 1, FormHeight + 1), OLshade
TheForm.Line (0, FormHeight - 1)-(FormWidth, FormHeight - 1), OLshade
For i = 1 To Thick
CurLeft = FormLeft + i + Distance
CurTop = FormTop + i + Distance
CurWide = FormWidth - (i + Distance) * 2 - 1
CurHigh = FormHeight - (i + Distance) * 2 - 1
TheForm.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
TheForm.Line -Step(0, CurHigh), BRshade
TheForm.Line -Step(-CurWide, 0), BRshade
TheForm.Line -Step(0, -CurHigh), TLshade
Next i
Case 1 To 3:
If Thickness = 1 Then
TheForm.Line (Thick, Thick)-(FormWidth - Thick, Thick), TLshade
TheForm.Line (Thick, Thick)-(Thick, FormHeight - Thick), TLshade
TheForm.Line (FormWidth - Thick, Thick)-(FormWidth - Thick, FormHeight - Thick + 1), BRshade
TheForm.Line (Thick, FormHeight - Thick)-(FormWidth - Thick, FormHeight - Thick), BRshade
Else
For i = 1 To Thick
CurLeft = FormLeft + i - 1 + Distance
CurTop = FormTop + i - 1 + Distance
CurWide = FormWidth - (i + Distance) * 2 + 1
CurHigh = FormHeight - (i + Distance) * 2 + 1
TheForm.Line (CurLeft, CurTop)-Step(CurWide, 0), TLshade
TheForm.Line -Step(0, CurHigh), BRshade
TheForm.Line -Step(-CurWide, 0), BRshade
TheForm.Line -Step(0, -CurHigh), TLshade
Next i
End If
End Select
TheForm.ScaleMode = OldMode
TheForm.DrawWidth = OldWidth
End Sub
Sub FillArray (array() As String, FillValue As String, low As Integer, high As Integer)
'PURPOSE: fills an array (or a portion thereof) with a specified value
'Comment: * low is the array element to start with
' * high is the array element to end with
' * to include entire array, set
' low to LBOUND of the array and
' high to UBOUND of the array
lb% = LBound(array)
ub% = UBound(array)
If low < lb% Then
MsgBox "Illegal Low Limit", 16, "FillArray Error"
Exit Sub
End If
If high > ub% Then
MsgBox "Illegal High Limit", 16, "FillArray Error"
Exit Sub
End If
For x = low To high
array(x) = FillValue
Next x
End Sub
Sub FormCenterForm (TheForm As Form, MainForm As Form)
TheForm.Move MainForm.Left + (MainForm.Width - TheForm.Width) / 2, MainForm.Top + (MainForm.Height - TheForm.Height) / 2
End Sub
Sub FormCenterScreen (TheForm As Form)
TheForm.Move (Screen.Width - TheForm.Width) / 2, (Screen.Height - TheForm.Height) / 2
End Sub
Function GetWinDir ()
Buffer$ = Space$(255)
count% = GetWindowsDirectory(Buffer$, 255)
GetWinDir = Left$(Buffer$, count%)
End Function
Sub ListHscroll (TheListBox As Control, CharsWide%)
If CharsWide% > 15000 Then CharsWide% = 15000
LongString$ = String$(CharsWide%, "W")
tppx% = Screen.TwipsPerPixelX
MaxiWide% = TheListBox.Parent.TextWidth(LongString$) / tppx%
HscrollLen& = SendMessage(TheListBox.hWnd, 1045, MaxiWide%, 0)
End Sub
Sub ReadData (ThisArray$(), ArrayString$, ArrayCount%)
'ThisArray$() is the array in which to place the strings
'ArrayString$ is the comma delimited string
'ArrayCount% will contain count of data
lpDelimiters$ = ","
ArrayCount% = GetTokenCount(ArrayString$, lpDelimiters$)
ReDim Preserve ThisArray$(ArrayCount%)
For x% = 1 To ArrayCount%
ReturnString$ = Space$(255)
GetToken ArrayString$, lpDelimiters$, x%, ReturnString$
TrimAtNull ReturnString$
ThisArray$(x%) = ReturnString$
Next x%
End Sub
Sub SortArray (ThisArray() As String, low As Integer, high As Integer)
'PURPOSE: sorts an array (or a portion thereof) with a specified value
'Comment: * low is the array element to start with
' * high is the array element to end with
' * to include entire array, set
' low to LBOUND of the array and
' high to UBOUND of the array
Dim i%, j%
Dim Temp$
lb% = LBound(ThisArray)
ub% = UBound(ThisArray)
If low < lb% Then
MsgBox "Illegal Low Limit", 16, "SortArray Error"
Exit Sub
End If
If high > ub% Then
MsgBox "Illegal High Limit", 16, "SortArray Error"
Exit Sub
End If
For i = low To high
For j = low To high - 1
If ThisArray(j) > ThisArray(j + 1) Then
Temp$ = ThisArray(j + 1)
ThisArray(j + 1) = ThisArray(j)
ThisArray(j) = Temp$
End If
Next j
Next i
End Sub
Function Strip (x As String, y As String)
'strips all occurences of Y string from X string
Dim z As String
If Len(x) < 1 Or Len(y) < 1 Then
Strip = ""
Exit Function
End If
Start = 1
z = x
Do
pos% = InStr(x, y)
If pos% = 0 Then Strip = z: Exit Function
z = Left$(x, (pos% - 1)) + Mid$(x, pos% + Len(y), Len(x) - Len(y) - pos% + 1)
If Start = Len(x) Then Exit Do
Start = Start + 1
Loop
Strip = z
End Function
Sub TrimAtNull (TheWord$)
'this sub removes the NULL, chr$(0), at the end of
'strings returned from DLL's
pos% = InStr(TheWord$, Chr$(0))
If pos% = 0 Then Exit Sub
TheWord$ = Left$(TheWord$, pos% - 1)
End Sub