home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Build_big_2222293292012.psc / frmMain.frm < prev    next >
Text File  |  2012-03-23  |  16KB  |  488 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Build Big Files"
  5.    ClientHeight    =   3105
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2400
  8.    ClientWidth     =   5880
  9.    Icon            =   "frmMain.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3105
  14.    ScaleWidth      =   5880
  15.    Begin VB.CommandButton cmdChoice 
  16.       Caption         =   "&Stop"
  17.       BeginProperty Font 
  18.          Name            =   "Arial"
  19.          Size            =   9.75
  20.          Charset         =   0
  21.          Weight          =   400
  22.          Underline       =   0   'False
  23.          Italic          =   0   'False
  24.          Strikethrough   =   0   'False
  25.       EndProperty
  26.       Height          =   600
  27.       Index           =   1
  28.       Left            =   4545
  29.       TabIndex        =   4
  30.       Top             =   2385
  31.       Width           =   555
  32.    End
  33.    Begin VB.PictureBox picFrame 
  34.       Appearance      =   0  'Flat
  35.       ForeColor       =   &H80000008&
  36.       Height          =   1500
  37.       Left            =   90
  38.       ScaleHeight     =   1470
  39.       ScaleWidth      =   5655
  40.       TabIndex        =   8
  41.       Top             =   720
  42.       Width           =   5685
  43.       Begin VB.CommandButton cmdPath 
  44.          Height          =   375
  45.          Left            =   5175
  46.          Picture         =   "frmMain.frx":0442
  47.          Style           =   1  'Graphical
  48.          TabIndex        =   3
  49.          Top             =   855
  50.          Width           =   420
  51.       End
  52.       Begin VB.OptionButton optOneBigFile 
  53.          Caption         =   "Yes"
  54.          Height          =   240
  55.          Index           =   1
  56.          Left            =   4905
  57.          TabIndex        =   2
  58.          Top             =   270
  59.          Width           =   600
  60.       End
  61.       Begin VB.OptionButton optOneBigFile 
  62.          Caption         =   "No"
  63.          Height          =   240
  64.          Index           =   0
  65.          Left            =   4275
  66.          TabIndex        =   1
  67.          Top             =   270
  68.          Value           =   -1  'True
  69.          Width           =   555
  70.       End
  71.       Begin VB.TextBox txtTargetPath 
  72.          BackColor       =   &H00FFFFC0&
  73.          BeginProperty Font 
  74.             Name            =   "Arial"
  75.             Size            =   9.75
  76.             Charset         =   0
  77.             Weight          =   400
  78.             Underline       =   0   'False
  79.             Italic          =   0   'False
  80.             Strikethrough   =   0   'False
  81.          EndProperty
  82.          Height          =   330
  83.          Left            =   90
  84.          Locked          =   -1  'True
  85.          TabIndex        =   7
  86.          TabStop         =   0   'False
  87.          Text            =   "txtTargetPath"
  88.          Top             =   855
  89.          Width           =   5010
  90.       End
  91.       Begin VB.TextBox txtQty 
  92.          Alignment       =   2  'Center
  93.          BeginProperty Font 
  94.             Name            =   "Arial"
  95.             Size            =   9
  96.             Charset         =   0
  97.             Weight          =   400
  98.             Underline       =   0   'False
  99.             Italic          =   0   'False
  100.             Strikethrough   =   0   'False
  101.          EndProperty
  102.          Height          =   330
  103.          Left            =   1980
  104.          MaxLength       =   2
  105.          TabIndex        =   0
  106.          Text            =   "txtQty"
  107.          Top             =   225
  108.          Width           =   510
  109.       End
  110.       Begin VB.Label lblFiles 
  111.          BackStyle       =   0  'Transparent
  112.          Caption         =   "Create one big file"
  113.          BeginProperty Font 
  114.             Name            =   "Arial"
  115.             Size            =   8.25
  116.             Charset         =   0
  117.             Weight          =   400
  118.             Underline       =   0   'False
  119.             Italic          =   0   'False
  120.             Strikethrough   =   0   'False
  121.          EndProperty
  122.          Height          =   240
  123.          Index           =   1
  124.          Left            =   2880
  125.          TabIndex        =   14
  126.          Top             =   270
  127.          Width           =   1320
  128.       End
  129.       Begin VB.Label lblFiles 
  130.          BackStyle       =   0  'Transparent
  131.          Caption         =   "Target path"
  132.          BeginProperty Font 
  133.             Name            =   "Arial"
  134.             Size            =   8.25
  135.             Charset         =   0
  136.             Weight          =   400
  137.             Underline       =   0   'False
  138.             Italic          =   0   'False
  139.             Strikethrough   =   0   'False
  140.          EndProperty
  141.          Height          =   240
  142.          Index           =   2
  143.          Left            =   90
  144.          TabIndex        =   13
  145.          Top             =   630
  146.          Width           =   1230
  147.       End
  148.       Begin VB.Label lblFiles 
  149.          Caption         =   "Number of files to create"
  150.          BeginProperty Font 
  151.             Name            =   "Arial"
  152.             Size            =   8.25
  153.             Charset         =   0
  154.             Weight          =   400
  155.             Underline       =   0   'False
  156.             Italic          =   0   'False
  157.             Strikethrough   =   0   'False
  158.          EndProperty
  159.          Height          =   240
  160.          Index           =   0
  161.          Left            =   90
  162.          TabIndex        =   9
  163.          Top             =   270
  164.          Width           =   1950
  165.       End
  166.    End
  167.    Begin VB.CommandButton cmdChoice 
  168.       Caption         =   "E&xit"
  169.       BeginProperty Font 
  170.          Name            =   "Arial"
  171.          Size            =   9.75
  172.          Charset         =   0
  173.          Weight          =   400
  174.          Underline       =   0   'False
  175.          Italic          =   0   'False
  176.          Strikethrough   =   0   'False
  177.       EndProperty
  178.       Height          =   600
  179.       Index           =   2
  180.       Left            =   5175
  181.       TabIndex        =   6
  182.       Top             =   2385
  183.       Width           =   555
  184.    End
  185.    Begin VB.CommandButton cmdChoice 
  186.       Caption         =   "&Go"
  187.       BeginProperty Font 
  188.          Name            =   "Arial"
  189.          Size            =   9.75
  190.          Charset         =   0
  191.          Weight          =   400
  192.          Underline       =   0   'False
  193.          Italic          =   0   'False
  194.          Strikethrough   =   0   'False
  195.       EndProperty
  196.       Height          =   600
  197.       Index           =   0
  198.       Left            =   4545
  199.       TabIndex        =   5
  200.       Top             =   2385
  201.       Width           =   555
  202.    End
  203.    Begin VB.Label lblAuthor 
  204.       Alignment       =   2  'Center
  205.       Appearance      =   0  'Flat
  206.       AutoSize        =   -1  'True
  207.       BackColor       =   &H80000005&
  208.       BackStyle       =   0  'Transparent
  209.       Caption         =   "Kenneth Ives"
  210.       BeginProperty Font 
  211.          Name            =   "Arial"
  212.          Size            =   9
  213.          Charset         =   0
  214.          Weight          =   400
  215.          Underline       =   -1  'True
  216.          Italic          =   0   'False
  217.          Strikethrough   =   0   'False
  218.       EndProperty
  219.       ForeColor       =   &H00FF0000&
  220.       Height          =   225
  221.       Left            =   2393
  222.       TabIndex        =   12
  223.       Top             =   405
  224.       Width           =   1095
  225.    End
  226.    Begin VB.Label lblTitle 
  227.       Alignment       =   2  'Center
  228.       BackStyle       =   0  'Transparent
  229.       Caption         =   "Build Big Files"
  230.       BeginProperty Font 
  231.          Name            =   "Arial"
  232.          Size            =   14.25
  233.          Charset         =   0
  234.          Weight          =   700
  235.          Underline       =   0   'False
  236.          Italic          =   0   'False
  237.          Strikethrough   =   0   'False
  238.       EndProperty
  239.       Height          =   330
  240.       Left            =   1785
  241.       TabIndex        =   11
  242.       Top             =   90
  243.       Width           =   2310
  244.    End
  245.    Begin VB.Label lblDisclaimer 
  246.       BackStyle       =   0  'Transparent
  247.       Caption         =   "lblDisclaimer"
  248.       BeginProperty Font 
  249.          Name            =   "Arial"
  250.          Size            =   8.25
  251.          Charset         =   0
  252.          Weight          =   400
  253.          Underline       =   0   'False
  254.          Italic          =   0   'False
  255.          Strikethrough   =   0   'False
  256.       EndProperty
  257.       Height          =   405
  258.       Left            =   135
  259.       TabIndex        =   10
  260.       Top             =   2475
  261.       Width           =   3855
  262.    End
  263. End
  264. Attribute VB_Name = "frmMain"
  265. Attribute VB_GlobalNameSpace = False
  266. Attribute VB_Creatable = False
  267. Attribute VB_PredeclaredId = True
  268. Attribute VB_Exposed = False
  269. ' ***************************************************************************
  270. ' Routine:       frmMain
  271. '
  272. ' Description:   Build GOST S-Box table sets and Skipjack F-Table sets.
  273. '
  274. ' ===========================================================================
  275. '    DATE      NAME / eMAIL
  276. '              DESCRIPTION
  277. ' -----------  --------------------------------------------------------------
  278. ' 06-Sep-2010  Kenneth Ives  kenaso@tx.rr.com
  279. '              Wrote module
  280. ' ***************************************************************************
  281. Option Explicit
  282.  
  283. ' ***************************************************************************
  284. ' Constants
  285. ' ***************************************************************************
  286.   Private Const MIN_QTY As Long = 1
  287.   Private Const MAX_QTY As Long = 10
  288.  
  289. ' ***************************************************************************
  290. ' Module Variables
  291. '
  292. ' Variable name:     mblnOneBigFile
  293. ' Naming standard:   m bln OneBigFile
  294. '                    - --- ----------
  295. '                    |  |   |_______ Variable subname
  296. '                    |  |___________ Data type (Boolean)
  297. '                    |______________ Module level designator
  298. '
  299. ' ***************************************************************************
  300.   Private mblnOneBigFile As Boolean
  301.   Private mstrTargetPath As String
  302.   Private mlngFileCnt    As Long
  303.   
  304. Private Sub SetControls()
  305.  
  306.     DoEvents
  307.     With frmMain
  308.         .picFrame.Enabled = False      ' main frame
  309.         .cmdChoice(0).Visible = False  ' Go button
  310.         .cmdChoice(0).Enabled = False
  311.         .cmdChoice(1).Enabled = True   ' Stop button
  312.         .cmdChoice(1).Visible = True
  313.         .cmdChoice(2).Enabled = False  ' Exit button
  314.     End With
  315.                 
  316. End Sub
  317.  
  318. Private Sub ResetControls()
  319.  
  320.     DoEvents
  321.     With frmMain
  322.         .picFrame.Enabled = True       ' main frame
  323.         .cmdChoice(0).Enabled = True   ' Go button
  324.         .cmdChoice(0).Visible = True
  325.         .cmdChoice(1).Visible = False  ' Stop button
  326.         .cmdChoice(1).Enabled = False
  327.         .cmdChoice(2).Enabled = True   ' Exit button
  328.     End With
  329.     
  330. End Sub
  331.  
  332. Private Function IsGoodData() As Boolean
  333.  
  334.     ' Test here instead of Lost_Focus event
  335.     ' so user is not forced to enter data
  336.     ' if attempting to exit application
  337.     
  338.     IsGoodData = False   ' Preset to FALSE
  339.     
  340.     If Not IsNumeric(txtQty.Text) Then
  341.         
  342.         InfoMsg "Quantity must be numeric." & vbNewLine & _
  343.                 "Min=" & CStr(MIN_QTY) & "    Max=" & CStr(MAX_QTY)
  344.         txtQty.SetFocus   ' Highlight quantity textbox
  345.     
  346.     ElseIf Val(txtQty.Text) < MIN_QTY Then
  347.         
  348.         InfoMsg "Quantity must be greater than zero." & vbNewLine & _
  349.                 "Min=" & CStr(MIN_QTY) & "    Max=" & CStr(MAX_QTY)
  350.         txtQty.SetFocus   ' Highlight quantity textbox
  351.     
  352.     ElseIf Val(txtQty.Text) > MAX_QTY Then
  353.         
  354.         InfoMsg "Quantity exceeds maximum range." & vbNewLine & _
  355.                 "Min=" & CStr(MIN_QTY) & "    Max=" & CStr(MAX_QTY)
  356.         txtQty.SetFocus   ' Highlight quantity textbox
  357.     
  358.     ElseIf Len(txtTargetPath.Text) = 0 Then
  359.         
  360.         InfoMsg "Destination path is empty."
  361.         txtTargetPath.SetFocus   ' Highlight path textbox
  362.     
  363.     Else
  364.         
  365.         IsGoodData = True                ' Set flag for good data
  366.         mlngFileCnt = CLng(txtQty.Text)  ' Save number of files to be created
  367.         
  368.     End If
  369.     
  370. End Function
  371.  
  372. Private Sub cmdChoice_Click(Index As Integer)
  373.  
  374.     Select Case Index
  375.             
  376.            Case 0  ' GO button
  377.            
  378.                 gblnStopProcessing = False
  379.                 DoEvents
  380.                 
  381.                 ' Evaluate textbox data
  382.                 If IsGoodData Then
  383.                     SetControls   ' Reset buttons before starting
  384.                     CreateBigFile mstrTargetPath, mlngFileCnt, mblnOneBigFile
  385.                 End If
  386.                 
  387.                 ResetControls  ' Reset buttons when finished
  388.            
  389.            Case 1  ' Stop button
  390.                 gblnStopProcessing = True  ' Reset boolean flag
  391.                 ResetControls              ' Reset buttons when finished
  392.                 DoEvents                   ' Allow time for notification process
  393.                 
  394.            Case Else
  395.                 DoEvents
  396.                 gblnStopProcessing = True  ' Reset boolean flag
  397.                 TerminateProgram           ' End this application
  398.     End Select
  399.     
  400. End Sub
  401.  
  402. Private Sub cmdPath_Click()
  403.  
  404.     Dim objBrowse As cBrowse
  405.     
  406.     Set objBrowse = New cBrowse   ' Instantiate class module
  407.     mstrTargetPath = objBrowse.BrowseForFolder(frmMain, "Select destination folder")
  408.     Set objBrowse = Nothing       ' Free class object from memory
  409.     
  410.     ' see if a folder was selected
  411.     If Len(Trim$(mstrTargetPath)) > 0 Then
  412.         txtTargetPath.Text = ShrinkToFit(mstrTargetPath, 50)
  413.     Else
  414.         txtTargetPath.Text = vbNullString
  415.     End If
  416.     
  417. End Sub
  418.  
  419. Private Sub Form_Load()
  420.  
  421.     mblnOneBigFile = True
  422.     mstrTargetPath = vbNullString
  423.     ResetControls
  424.     
  425.     With frmMain
  426.         .Caption = PGM_NAME & gstrVersion
  427.         .lblDisclaimer.Caption = "This is a freeware product." & vbNewLine & _
  428.                                  "No warranties or guarantees implied or intended."
  429.                                  
  430.         .txtQty.Text = 1
  431.         .txtTargetPath.Text = vbNullString
  432.         
  433.         .optOneBigFile(0).Value = True  ' Select No
  434.         optOneBigFile_Click 0           ' Toggle boolean flag to No
  435.         
  436.         ' Center form on screen
  437.         .Move (Screen.Width - .Width) \ 2, (Screen.Height - .Height) \ 2
  438.         .Show
  439.     End With
  440.  
  441. End Sub
  442.  
  443. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  444.  
  445.     If UnloadMode = 0 Then
  446.         TerminateProgram   ' "X" selected in upper right corner
  447.     End If
  448.     
  449. End Sub
  450.  
  451. Private Sub lblAuthor_Click()
  452.     SendEmail   ' Send email to author of this application
  453. End Sub
  454.  
  455. Private Sub optOneBigFile_Click(Index As Integer)
  456.     
  457.     mblnOneBigFile = Not mblnOneBigFile  ' Toggle value
  458.     
  459. End Sub
  460.  
  461. Private Sub txtQty_GotFocus()
  462.  
  463.     ' Highlight all data in textbox
  464.     With txtQty
  465.          .SelStart = 0             ' start with first char
  466.          .SelLength = Len(.Text)   ' to end of data string
  467.     End With
  468.   
  469. End Sub
  470.  
  471. Private Sub txtQty_KeyPress(KeyAscii As Integer)
  472.  
  473.     ' Evaluate data as it is entered into textbox
  474.     Select Case KeyAscii
  475.            Case 9             ' Tab key
  476.                 KeyAscii = 0
  477.                 SendKeys "{TAB}"
  478.            Case 13            ' Enter key (no bell sound)
  479.                 KeyAscii = 0
  480.            Case 8, 48 To 57   ' backspace & numeric keys only
  481.                 ' good data
  482.            Case Else          ' everything else
  483.                 KeyAscii = 0
  484.     End Select
  485.                               
  486. End Sub
  487.  
  488.