home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LVB / T2W32543.ZIP / _MISC.FRM < prev    next >
Text File  |  1998-05-21  |  17KB  |  642 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMisc 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Miscelleanous"
  5.    ClientHeight    =   4785
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    MaxButton       =   0   'False
  10.    MDIChild        =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   4785
  13.    ScaleWidth      =   7485
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame1 
  16.       Height          =   570
  17.       Left            =   0
  18.       TabIndex        =   1
  19.       Top             =   -90
  20.       Width           =   7485
  21.       Begin VB.CommandButton cmdNP 
  22.          Caption         =   ">"
  23.          Height          =   285
  24.          Index           =   1
  25.          Left            =   7110
  26.          TabIndex        =   6
  27.          Top             =   195
  28.          Width           =   285
  29.       End
  30.       Begin VB.CommandButton cmdNP 
  31.          Caption         =   "<"
  32.          Height          =   285
  33.          Index           =   0
  34.          Left            =   6210
  35.          TabIndex        =   5
  36.          Top             =   195
  37.          Width           =   285
  38.       End
  39.       Begin VB.CommandButton Command1 
  40.          Caption         =   "&Go"
  41.          Default         =   -1  'True
  42.          Height          =   285
  43.          Left            =   6570
  44.          TabIndex        =   4
  45.          Top             =   195
  46.          Width           =   465
  47.       End
  48.       Begin VB.ComboBox cmb_Function 
  49.          Height          =   315
  50.          Left            =   1365
  51.          TabIndex        =   2
  52.          Top             =   180
  53.          Width           =   4755
  54.       End
  55.       Begin VB.Label Label2 
  56.          Caption         =   "&Select a function"
  57.          Height          =   255
  58.          Left            =   90
  59.          TabIndex        =   3
  60.          Top             =   210
  61.          Width           =   1275
  62.       End
  63.    End
  64.    Begin VB.TextBox txt_Result 
  65.       BackColor       =   &H00C0C0C0&
  66.       BorderStyle     =   0  'None
  67.       Height          =   4005
  68.       Left            =   105
  69.       Locked          =   -1  'True
  70.       MultiLine       =   -1  'True
  71.       ScrollBars      =   2  'Vertical
  72.       TabIndex        =   0
  73.       Top             =   630
  74.       Width           =   7260
  75.    End
  76. End
  77. Attribute VB_Name = "frmMisc"
  78. Attribute VB_GlobalNameSpace = False
  79. Attribute VB_Creatable = False
  80. Attribute VB_PredeclaredId = True
  81. Attribute VB_Exposed = False
  82. Option Explicit
  83. Option Base 1
  84.  
  85. Private Const Iteration = 250
  86.  
  87. Dim IsLoaded         As Integer
  88.  
  89. Dim TimerStartOk     As Integer
  90. Dim TimerCloseOk     As Integer
  91.  
  92. Dim TimerHandle      As Integer
  93. Dim TimerValue       As Long
  94.  
  95. Private Sub cmdNP_Click(Index As Integer)
  96.  
  97.    Call sub_NextPrev(cmb_Function, Index)
  98.  
  99. End Sub
  100.  
  101.  
  102. Private Sub cmb_Function_Click()
  103.    
  104.    If (IsLoaded = False) Then Exit Sub
  105.    
  106.    Call cDisableFI(mdiT2W.Picture1)
  107.    
  108.    txt_Result = ""
  109.    
  110.    DoEvents
  111.    
  112.    Select Case cmb_Function.ListIndex
  113.       Case 0
  114.          Call TestSwapX
  115.       Case 1
  116.          Call TestMinMax
  117.       Case 2
  118.          Call TestIncrX
  119.       Case 3
  120.          Call TestRndX
  121.       Case 4
  122.          Call TestSpellMoney
  123.       Case 5
  124.          Call TestFraction
  125.       Case 6
  126.          Call TestBaseConversion
  127.       Case 7
  128.          Call TestCombination
  129.    End Select
  130.  
  131.    DoEvents
  132.    Call cEnableFI(mdiT2W.Picture1)
  133.    
  134. End Sub
  135.  
  136.  
  137. Private Sub Form_Activate()
  138.  
  139.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  140.  
  141. End Sub
  142.  
  143. Private Sub Form_Load()
  144.  
  145.    IsLoaded = False
  146.    
  147.    Show
  148.  
  149.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_misc.t2w")
  150.    
  151.    IsLoaded = True
  152.    
  153. End Sub
  154.  
  155. Private Sub Command1_Click()
  156.    
  157.    Call cmb_Function_Click
  158.    
  159. End Sub
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. Private Sub TestSwapX()
  168.  
  169.    Dim intResult        As Integer
  170.    Dim strResult        As String
  171.    Dim strDisplay       As String
  172.    
  173.    Dim i                As Integer
  174.    
  175.    Dim Str1             As String
  176.    Dim Str2             As String
  177.    
  178.    Dim b1               As Byte
  179.    Dim b2               As Byte
  180.    Dim i1               As Integer
  181.    Dim i2               As Integer
  182.    Dim l1               As Long
  183.    Dim l2               As Long
  184.    Dim s1               As Single
  185.    Dim s2               As Single
  186.    Dim d1               As Double
  187.    Dim d2               As Double
  188.    
  189.    strResult = ""
  190.    strDisplay = ""
  191.    
  192.    Str1 = "Hello"
  193.    Str2 = "World"
  194.    
  195.    b1 = 0
  196.    b2 = 255
  197.    i1 = -32768
  198.    i2 = 32767
  199.    l1 = -2147483647
  200.    l2 = 2147483647
  201.    s1 = 12345.5678
  202.    s2 = 98765.4321
  203.    d1 = 12345.67890123
  204.    d2 = 98765.43210987
  205.    
  206.    strDisplay = strDisplay + "SwapB of '" & b1 & " - " & b2 & "' is "
  207.    Call cSwapB(b1, b2)
  208.    strDisplay = strDisplay + "'" & b1 & " - " & b2 & "'" & vbCrLf & vbCrLf
  209.  
  210.    strDisplay = strDisplay + "SwapI of '" & i1 & " - " & i2 & "' is "
  211.    Call cSwapI(i1, i2)
  212.    strDisplay = strDisplay + "'" & i1 & " - " & i2 & "'" & vbCrLf & vbCrLf
  213.  
  214.    strDisplay = strDisplay + "SwapL of '" & l1 & " - " & l2 & "' is "
  215.    Call cSwapL(l1, l2)
  216.    strDisplay = strDisplay + "'" & l1 & " - " & l2 & "'" & vbCrLf & vbCrLf
  217.  
  218.    strDisplay = strDisplay + "SwapS of '" & s1 & " - " & s2 & "' is "
  219.    Call cSwapS(s1, s2)
  220.    strDisplay = strDisplay + "'" & s1 & " - " & s2 & "'" & vbCrLf & vbCrLf
  221.  
  222.    strDisplay = strDisplay + "SwapD of '" & d1 & " - " & d2 & "' is "
  223.    Call cSwapD(d1, d2)
  224.    strDisplay = strDisplay + "'" & d1 & " - " & d2 & "'" & vbCrLf & vbCrLf
  225.  
  226.    strDisplay = strDisplay + "SwapStr of '" & Str1 & " - " & Str2 & "' is "
  227.    Call cSwapStr(Str1, Str2)
  228.    strDisplay = strDisplay + "'" & Str1 & " - " & Str2 & "'" & vbCrLf & vbCrLf
  229.  
  230.    strDisplay = strDisplay + "SwapStr of '" & Str1 & " - " & Str2 & "' is "
  231.    Call cSwapStr(Str1, Str2)
  232.    strDisplay = strDisplay + "'" & Str1 & " - " & Str2 & "'"
  233.      
  234.    txt_Result = strDisplay
  235.  
  236.    'time the function
  237.  
  238.    TimerHandle = cTimerOpen()
  239.    TimerStartOk = cTimerStart(TimerHandle)
  240.    
  241.    For i = 1 To Iteration
  242.       Call cSwapD(d1, d2)
  243.    Next i
  244.    
  245.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  246.    
  247.    TimerCloseOk = cTimerClose(TimerHandle)
  248.  
  249. End Sub
  250.  
  251. Private Sub TestMinMax()
  252.    
  253.    Dim lResult          As Long
  254.    Dim strResult        As String
  255.    Dim strDisplay       As String
  256.    
  257.    Dim i                As Integer
  258.    
  259.    Dim Str1             As String
  260.    Dim Str2             As String
  261.    
  262.    lResult = 0
  263.    
  264.    strResult = ""
  265.    strDisplay = ""
  266.      
  267.    strDisplay = strDisplay & "Min of '32760,1234567' is '" & cMin(32760, 1234567) & "'" & vbCrLf & vbCrLf
  268.    
  269.    strDisplay = strDisplay & "Max of '32760,1234567' is '" & cMax(32760, 1234567) & "'"
  270.    
  271.    txt_Result = strDisplay
  272.  
  273.    'time the function
  274.  
  275.    TimerHandle = cTimerOpen()
  276.    TimerStartOk = cTimerStart(TimerHandle)
  277.    
  278.    For i = 1 To Iteration
  279.       lResult = cMax(32760, 1234567)
  280.    Next i
  281.    
  282.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  283.    
  284.    TimerCloseOk = cTimerClose(TimerHandle)
  285.  
  286. End Sub
  287.  
  288. Private Sub TestIncrX()
  289.    
  290.    Dim lResult          As Long
  291.    Dim strResult        As String
  292.    Dim strDisplay       As String
  293.    
  294.    Dim i                As Integer
  295.    
  296.    Dim Str1             As String
  297.    Dim Str2             As String
  298.    
  299.    lResult = 0
  300.    
  301.    strResult = ""
  302.    strDisplay = ""
  303.      
  304.    i = 1
  305.    Call cIncrI(i)
  306.    strDisplay = strDisplay & "IncrI of '" & 1 & "' is '" & i & "'" & vbCrLf
  307.    i = 32000
  308.    Call cIncrI(i)
  309.    strDisplay = strDisplay & "IncrI of '" & 32000 & "' is '" & i & "'" & vbCrLf
  310.    i = -32768
  311.    Call cIncrI(i)
  312.    strDisplay = strDisplay & "IncrI of '" & -32768 & "' is '" & i & "'" & vbCrLf & vbCrLf
  313.    
  314.    i = 1
  315.    Call cDecrI(i)
  316.    strDisplay = strDisplay & "DecrI of '" & 1 & "' is '" & i & "'" & vbCrLf
  317.    i = 32000
  318.    Call cDecrI(i)
  319.    strDisplay = strDisplay & "DecrI of '" & 32000 & "' is '" & i & "'" & vbCrLf
  320.    i = -32767
  321.    Call cDecrI(i)
  322.    strDisplay = strDisplay & "DecrI of '" & -32767 & "' is '" & i & "'" & vbCrLf & vbCrLf
  323.    
  324.    lResult = 1
  325.    Call cIncrL(lResult)
  326.    strDisplay = strDisplay & "IncrL of '" & 1 & "' is '" & lResult & "'" & vbCrLf
  327.    lResult = 32000
  328.    Call cIncrL(lResult)
  329.    strDisplay = strDisplay & "IncrL of '" & 32000 & "' is '" & lResult & "'" & vbCrLf
  330.    lResult = -32768
  331.    Call cIncrL(lResult)
  332.    strDisplay = strDisplay & "IncrL of '" & -32768 & "' is '" & lResult & "'" & vbCrLf & vbCrLf
  333.    
  334.    lResult = 1
  335.    Call cDecrL(lResult)
  336.    strDisplay = strDisplay & "DecrL of '" & 1 & "' is '" & lResult & "'" & vbCrLf
  337.    lResult = 32000
  338.    Call cDecrL(lResult)
  339.    strDisplay = strDisplay & "DecrL of '" & 32000 & "' is '" & lResult & "'" & vbCrLf
  340.    lResult = -32768
  341.    Call cDecrL(lResult)
  342.    strDisplay = strDisplay & "DecrL of '" & -32768 & "' is '" & lResult & "'"
  343.    
  344.    txt_Result = strDisplay
  345.  
  346.    'time the function
  347.  
  348.    TimerHandle = cTimerOpen()
  349.    TimerStartOk = cTimerStart(TimerHandle)
  350.    
  351.    For i = 1 To Iteration
  352.       Call cIncrI(i)
  353.    Next i
  354.    
  355.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  356.    
  357.    TimerCloseOk = cTimerClose(TimerHandle)
  358.  
  359. End Sub
  360.  
  361. Private Sub TestRndX()
  362.    
  363.    Dim lResult          As Long
  364.    Dim strResult        As String
  365.    Dim strDisplay       As String
  366.    
  367.    Dim i                As Integer
  368.    
  369.    Dim Str1             As String
  370.    Dim Str2             As String
  371.    
  372.    lResult = 0
  373.    
  374.    strResult = ""
  375.    strDisplay = ""
  376.      
  377.    Call cRndInit(-1)
  378.    
  379.    strDisplay = "Some random Integer number" & vbCrLf & vbCrLf
  380.  
  381.    For i = 1 To 2
  382.       strDisplay = strDisplay & cRndI() & vbCrLf
  383.    Next i
  384.  
  385.    strDisplay = strDisplay & vbCrLf
  386.  
  387.    strDisplay = strDisplay & "Some random Long number" & vbCrLf & vbCrLf
  388.  
  389.    For i = 1 To 2
  390.       strDisplay = strDisplay & cRndL() & vbCrLf
  391.    Next i
  392.  
  393.    strDisplay = strDisplay & vbCrLf
  394.  
  395.    strDisplay = strDisplay & "Some random Single number" & vbCrLf & vbCrLf
  396.  
  397.    For i = 1 To 2
  398.       strDisplay = strDisplay & cRndS() & vbCrLf
  399.    Next i
  400.  
  401.    strDisplay = strDisplay & vbCrLf
  402.  
  403.    strDisplay = strDisplay & "Some random Double number" & vbCrLf & vbCrLf
  404.  
  405.    For i = 1 To 2
  406.       strDisplay = strDisplay & cRndD() & vbCrLf
  407.    Next i
  408.  
  409.    strDisplay = strDisplay & vbCrLf
  410.  
  411.    strDisplay = strDisplay & "Some random Double number between 0.0 and 1.0" & vbCrLf & vbCrLf
  412.  
  413.    For i = 1 To 2
  414.       strDisplay = strDisplay & cRnd() & vbCrLf
  415.    Next i
  416.    
  417.    txt_Result = strDisplay
  418.  
  419.    'time the function
  420.  
  421.    TimerHandle = cTimerOpen()
  422.    TimerStartOk = cTimerStart(TimerHandle)
  423.    
  424.    For i = 1 To Iteration
  425.       lResult = cRndL()
  426.    Next i
  427.    
  428.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  429.    
  430.    TimerCloseOk = cTimerClose(TimerHandle)
  431.  
  432. End Sub
  433.  
  434. Private Sub TestSpellMoney()
  435.    
  436.    Dim lResult          As Long
  437.    Dim strResult        As String
  438.    Dim strDisplay       As String
  439.    
  440.    Dim i                As Integer
  441.    
  442.    Dim Str1             As String
  443.    
  444.    Dim Units            As String
  445.    Dim Cents            As String
  446.  
  447.    lResult = 0
  448.    
  449.    strResult = ""
  450.    strDisplay = ""
  451.      
  452.    Units = "dollars"
  453.    Cents = "cents"
  454.  
  455.    strDisplay = "Spelling the following money value " & vbCrLf & vbCrLf
  456.  
  457.    strDisplay = strDisplay & "4.12 is '" & cSpellMoney(4.12, Units, Cents) & "'" & vbCrLf & vbCrLf
  458.    strDisplay = strDisplay & "16 is '" & cSpellMoney(16, Units, Cents) & "'" & vbCrLf & vbCrLf
  459.    strDisplay = strDisplay & "25 is '" & cSpellMoney(25, Units, Cents) & "'" & vbCrLf & vbCrLf
  460.    strDisplay = strDisplay & "34 is '" & cSpellMoney(34, Units, Cents) & "'" & vbCrLf & vbCrLf
  461.    strDisplay = strDisplay & "43 is '" & cSpellMoney(43, Units, Cents) & "'" & vbCrLf & vbCrLf
  462.    strDisplay = strDisplay & "61 is '" & cSpellMoney(61, Units, Cents) & "'" & vbCrLf & vbCrLf
  463.    strDisplay = strDisplay & "98765.43 is '" & cSpellMoney(98765.43, Units, Cents) & "'" & vbCrLf & vbCrLf
  464.    strDisplay = strDisplay & "123456789.75 is '" & cSpellMoney(123456789.75, Units, Cents) & "'"
  465.  
  466.    txt_Result = strDisplay
  467.  
  468.    'time the function
  469.  
  470.    TimerHandle = cTimerOpen()
  471.    TimerStartOk = cTimerStart(TimerHandle)
  472.    
  473.    For i = 1 To Iteration
  474.       strResult = cSpellMoney(12.34, Units, Cents)
  475.    Next i
  476.    
  477.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  478.    
  479.    TimerCloseOk = cTimerClose(TimerHandle)
  480.  
  481. End Sub
  482.  
  483. Private Sub TestFraction()
  484.    
  485.    Dim dblResult        As Double
  486.    Dim strResult        As String
  487.    Dim strDisplay       As String
  488.    
  489.    Dim i                As Integer
  490.    Dim v                As Double
  491.    Dim n                As Double
  492.    Dim p                As Double
  493.    Dim q                As Double
  494.    Dim e                As Integer
  495.    
  496.    Dim Str1             As String
  497.    
  498.    Dim Units            As String
  499.    Dim Cents            As String
  500.  
  501.    dblResult = 0
  502.    
  503.    strResult = ""
  504.    strDisplay = ""
  505.      
  506.    strDisplay = "Determining fraction part (numerator/denominator) for the following value " & vbCrLf & vbCrLf
  507.  
  508.    n = 4.12
  509.    v = cFraction(n, p, q)
  510.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  511.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  512.    
  513.    n = 1.75
  514.    v = cFraction(n, p, q)
  515.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  516.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  517.    
  518.    n = 0.5
  519.    v = cFraction(n, p, q)
  520.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  521.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  522.    
  523.    n = 365.25
  524.    v = cFraction(n, p, q)
  525.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  526.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  527.  
  528.    n = 3.14
  529.    v = cFraction(n, p, q)
  530.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  531.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  532.  
  533.    n = 3.14159
  534.    v = cFraction(n, p, q)
  535.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  536.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  537.  
  538.    n = 3.14159265
  539.    v = cFraction(n, p, q)
  540.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  541.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  542.  
  543.    n = 0.9999999
  544.    v = cFraction(n, p, q)
  545.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  546.    strDisplay = strDisplay & "   value is " & v
  547.  
  548.    txt_Result = strDisplay
  549.  
  550.    'time the function
  551.  
  552.    TimerHandle = cTimerOpen()
  553.    TimerStartOk = cTimerStart(TimerHandle)
  554.    
  555.    For i = 1 To Iteration
  556.       dblResult = cFraction(n, p, q)
  557.    Next i
  558.    
  559.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  560.    
  561.    TimerCloseOk = cTimerClose(TimerHandle)
  562.  
  563. End Sub
  564.  
  565. Private Sub TestBaseConversion()
  566.    
  567.    Dim lResult          As Long
  568.    Dim strResult        As String
  569.    Dim strDisplay       As String
  570.    
  571.    Dim i                As Integer
  572.    
  573.    Dim Str1             As String
  574.    
  575.    lResult = 0
  576.    
  577.    strResult = ""
  578.    strDisplay = ""
  579.      
  580.    For i = 1 To 34
  581.       strDisplay = strDisplay & "Convert '1234567' base 10 to base " & i & " is " & cBaseConversion("1234567", 10, i) & vbCrLf
  582.    Next i
  583.  
  584.    txt_Result = strDisplay
  585.  
  586.    'time the function
  587.  
  588.    TimerHandle = cTimerOpen()
  589.    TimerStartOk = cTimerStart(TimerHandle)
  590.    
  591.    For i = 1 To Iteration
  592.       strResult = cBaseConversion("123456789", 10, 10)
  593.    Next i
  594.    
  595.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  596.    
  597.    TimerCloseOk = cTimerClose(TimerHandle)
  598.  
  599. End Sub
  600.  
  601. Private Sub TestCombination()
  602.    
  603.    Dim dblResult        As Double
  604.    Dim strResult        As String
  605.    Dim strDisplay       As String
  606.    
  607.    Dim i                As Integer
  608.    
  609.    Dim Str1             As String
  610.    
  611.    dblResult = 0
  612.    
  613.    strResult = ""
  614.    strDisplay = ""
  615.      
  616.    For i = 0 To 10
  617.       strDisplay = strDisplay & "Combination C(42, " & i & ") is '" & cCombination(42, i) & "'" & vbCrLf
  618.    Next i
  619.  
  620.    strDisplay = strDisplay & vbCrLf
  621.  
  622.    For i = 42 To 32 Step -1
  623.       strDisplay = strDisplay & "Combination C(42, " & i & ") is '" & cCombination(42, i) & "'" & vbCrLf
  624.    Next i
  625.  
  626.    txt_Result = strDisplay
  627.  
  628.    'time the function
  629.  
  630.    TimerHandle = cTimerOpen()
  631.    TimerStartOk = cTimerStart(TimerHandle)
  632.    
  633.    For i = 1 To Iteration
  634.       dblResult = cCombination(42, 6)
  635.    Next i
  636.    
  637.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  638.    
  639.    TimerCloseOk = cTimerClose(TimerHandle)
  640.  
  641. End Sub
  642.