home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / crystal / extras / crpedemo / setformu.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-12-15  |  10.7 KB  |  321 lines

  1. VERSION 2.00
  2. Begin Form SetFormula 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Formulas"
  5.    ClientHeight    =   6675
  6.    ClientLeft      =   960
  7.    ClientTop       =   1410
  8.    ClientWidth     =   9660
  9.    Height          =   7080
  10.    Left            =   900
  11.    LinkTopic       =   "Form3"
  12.    ScaleHeight     =   7820.709
  13.    ScaleMode       =   0  'User
  14.    ScaleWidth      =   9660
  15.    Top             =   1065
  16.    Width           =   9780
  17.    Begin CommandButton Command9 
  18.       Caption         =   "Help"
  19.       Height          =   375
  20.       Left            =   7830
  21.       TabIndex        =   15
  22.       Top             =   1260
  23.       Width           =   1455
  24.    End
  25.    Begin CommandButton Command8 
  26.       Caption         =   "Ok"
  27.       Height          =   375
  28.       Left            =   7800
  29.       TabIndex        =   14
  30.       Top             =   360
  31.       Width           =   1485
  32.    End
  33.    Begin SSFrame Frame3D2 
  34.       Caption         =   "Group Selection Formula"
  35.       Font3D          =   0  'None
  36.       ForeColor       =   &H00000000&
  37.       Height          =   1860
  38.       Left            =   270
  39.       TabIndex        =   10
  40.       Top             =   4455
  41.       Width           =   7215
  42.       Begin TextBox Text3 
  43.          Height          =   1275
  44.          Left            =   1440
  45.          MultiLine       =   -1  'True
  46.          ScrollBars      =   2  'Vertical
  47.          TabIndex        =   13
  48.          Top             =   405
  49.          Width           =   5595
  50.       End
  51.       Begin CommandButton Command5 
  52.          Caption         =   "Check"
  53.          Height          =   375
  54.          Left            =   270
  55.          TabIndex        =   12
  56.          Top             =   1080
  57.          Width           =   1005
  58.       End
  59.       Begin CommandButton Command4 
  60.          Caption         =   "Set"
  61.          Height          =   375
  62.          Left            =   270
  63.          TabIndex        =   11
  64.          Top             =   585
  65.          Width           =   1005
  66.       End
  67.    End
  68.    Begin SSFrame Frame3D1 
  69.       Caption         =   "Selection Formula"
  70.       Font3D          =   0  'None
  71.       ForeColor       =   &H00000000&
  72.       Height          =   1905
  73.       Left            =   270
  74.       TabIndex        =   6
  75.       Top             =   2385
  76.       Width           =   7215
  77.       Begin CommandButton Command3 
  78.          Caption         =   "Check"
  79.          Height          =   375
  80.          Left            =   270
  81.          TabIndex        =   9
  82.          Top             =   1125
  83.          Width           =   1005
  84.       End
  85.       Begin CommandButton Command1 
  86.          Caption         =   "Set"
  87.          Height          =   375
  88.          Left            =   270
  89.          TabIndex        =   8
  90.          Top             =   630
  91.          Width           =   1005
  92.       End
  93.       Begin TextBox Text1 
  94.          Height          =   1230
  95.          Left            =   1350
  96.          MultiLine       =   -1  'True
  97.          ScrollBars      =   2  'Vertical
  98.          TabIndex        =   7
  99.          Top             =   450
  100.          Width           =   5595
  101.       End
  102.    End
  103.    Begin SSFrame Formulas 
  104.       Caption         =   "Formulas"
  105.       Font3D          =   0  'None
  106.       ForeColor       =   &H00000000&
  107.       Height          =   2025
  108.       Left            =   240
  109.       TabIndex        =   1
  110.       Top             =   210
  111.       Width           =   7215
  112.       Begin TextBox FormulaText 
  113.          Height          =   300
  114.          Left            =   180
  115.          TabIndex        =   16
  116.          Top             =   315
  117.          Width           =   2685
  118.       End
  119.       Begin CommandButton Command6 
  120.          Caption         =   "Check"
  121.          Height          =   375
  122.          Left            =   180
  123.          TabIndex        =   5
  124.          Top             =   1395
  125.          Width           =   1005
  126.       End
  127.       Begin CommandButton Command7 
  128.          Caption         =   "Set"
  129.          Enabled         =   0   'False
  130.          Height          =   375
  131.          Left            =   180
  132.          TabIndex        =   4
  133.          Top             =   900
  134.          Width           =   975
  135.       End
  136.       Begin ComboBox FormCombo 
  137.          Height          =   300
  138.          Left            =   180
  139.          Style           =   2  'Dropdown List
  140.          TabIndex        =   3
  141.          Top             =   315
  142.          Width           =   2925
  143.       End
  144.       Begin TextBox Text2 
  145.          Height          =   1080
  146.          Left            =   1350
  147.          MultiLine       =   -1  'True
  148.          ScrollBars      =   2  'Vertical
  149.          TabIndex        =   2
  150.          Top             =   810
  151.          Width           =   5625
  152.       End
  153.    End
  154.    Begin CommandButton Command2 
  155.       Caption         =   "Close"
  156.       Height          =   375
  157.       Left            =   7830
  158.       TabIndex        =   0
  159.       Top             =   810
  160.       Width           =   1455
  161.    End
  162. Dim FormulaName As String
  163. Dim SelectFormula As String
  164. Sub Command1_Click ()
  165.   If PESetSelectionFormula(JobNum, Text1.Text) = False Then
  166.       RCode = GetErrorString(JobNum)
  167.       MsgBox "PESetSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  168.       Exit Sub
  169.   Else
  170.     Main!StatusBar.Caption = "The Selection formula has been Set"
  171.   End If
  172. End Sub
  173. Sub Command2_Click ()
  174.  Unload Me
  175. End Sub
  176. Sub Command3_Click ()
  177.  If PECheckSelectionFormula(JobNum) = False Then
  178.       RCode = GetErrorString(JobNum)
  179.       MsgBox "PECheckSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  180.       Exit Sub
  181.   Else
  182.       MsgBox "No Errors Found"
  183.   End If
  184. End Sub
  185. Sub Command4_Click ()
  186. If PESetGroupSelectionFormula(JobNum, Text3.Text) = False Then
  187.       RCode = GetErrorString(JobNum)
  188.       MsgBox "PESetGroupSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  189.       Exit Sub
  190.     Main!StatusBar.Caption = "The Group Selection formula has been set"
  191. End If
  192. End Sub
  193. Sub Command5_Click ()
  194.  If PECheckGroupSelectionFormula(JobNum) = False Then
  195.       RCode = GetErrorString(JobNum)
  196.       MsgBox "PECheckGroupSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  197.       Exit Sub
  198.   Else
  199.       MsgBox "No Errors Found"
  200.   End If
  201. End Sub
  202. Sub Command6_Click ()
  203.  If PECheckFormula(JobNum, FormCombo.Text) = False Then
  204.       RCode = GetErrorString(JobNum)
  205.       MsgBox "PECheckFormula Error #: " + Str(ErrorCode) + " - " + RCode
  206.       Exit Sub
  207.   Else
  208.       MsgBox "No Errors Found"
  209.   End If
  210. End Sub
  211. Sub Command7_Click ()
  212. 'Set formula to pass to crystal Reports
  213. 'Notice that the string pointer must be embedded in quotes
  214. 'the formula name does not have quote surrounding it and does not include
  215. 'the @ sign as shown in Crystal Reports
  216.    If PESetFormula(JobNum, FormCombo.Text, Text2.Text) = False Then
  217.       RCode = GetErrorString(JobNum)
  218.       MsgBox "PESetFormula Error #: " + Str(ErrorCode) + " - " + RCode
  219.       Exit Sub
  220.    Else
  221.       Main!StatusBar.Caption = "The formula " + FormCombo.Text + " has been set to --->" + Text2.Text
  222.    End If
  223. End Sub
  224. Sub Command8_Click ()
  225. Unload Me
  226. End Sub
  227. Sub Command9_Click ()
  228.  RCode = Shell("Winhelp c:\crw\crw.hlp", 3)
  229.  If RCode = False Then
  230.    MsgBox ("CRWDEMO cannot find the Crystal Help file in C:\CRW directory")
  231.  End If
  232. End Sub
  233. Sub Form_Load ()
  234. 'Declarations
  235.  Dim I, NFormulas As Integer
  236.  Dim FormulaN As String
  237.  Dim SelectFormula As String
  238.  Dim GroupFormula
  239.  Dim FormHandle As Integer, FormLength As Integer, FormNameHandle As Integer, FormNameLength As Integer
  240.  Dim SelectHandle As Integer, SelectLength As Integer
  241.  Dim GrHandle As Integer, GrLength As Integer
  242. 'Retrieve number of formulas used in the report
  243. NFormulas = PEGetNFormulas(JobNum)
  244. 'Retrieve formula name for each formula in the report and populate the list box.
  245. For I = 0 To NFormulas - 1
  246.     If PEGetNthFormula(JobNum, I, FormNameHandle, FormNameLength, FormHandle, FormLength) = False Then
  247.       RCode = GetErrorString(JobNum)
  248.       MsgBox "PEGetFormula Error #: " + Str(ErrorCode) + " - " + RCode
  249.     End If
  250.     FormulaN = String(FormNameLength, " ")
  251.     If PEGetHandleString(FormNameHandle, FormulaN, FormNameLength) = False Then
  252.      ' Handle error
  253.       RCode = GetErrorString(JobNum)
  254.       MsgBox "PEGetHandleString Error #: " + Str(ErrorCode) + " - " + RCode
  255.     Else
  256.       FormCombo.AddItem FormulaN, I
  257.       If I = 0 Then
  258.         FormulaText.Text = FormulaN
  259.       End If
  260.     End If
  261. Next I
  262. 'Get the Selection formula and display in Text box
  263.   If PEGetSelectionFormula(JobNum, SelectHandle, SelectLength) = False Then
  264.       RCode = GetErrorString(JobNum)
  265.       MsgBox "PEGetGroupSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  266.       Exit Sub
  267.      
  268.   End If
  269.   ' Allocate memory for string
  270.   SelectFormula = String(SelectLength, " ")
  271.   If PEGetHandleString(SelectHandle, SelectFormula, SelectLength) = False Then
  272.       RCode = GetErrorString(JobNum)
  273.       MsgBox "PEGetSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  274.       Exit Sub
  275.   Else
  276.     Text1.Text = SelectFormula
  277.   End If
  278. 'Get Group Selection Formula
  279.   If PEGetGroupSelectionFormula(JobNum, GrHandle, GrLength) = False Then
  280.       RCode = GetErrorString(JobNum)
  281.       MsgBox "PEGetGroupSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  282.       Exit Sub
  283.      
  284.   End If
  285.   ' Allocate memory for string
  286.   GroupFormula = String(GrLength, " ")
  287.   If PEGetHandleString(GrHandle, GroupFormula, GrLength) = False Then
  288.       RCode = GetErrorString(JobNum)
  289.       MsgBox "PEGetGroupSelectionFormula Error #: " + Str(ErrorCode) + " - " + RCode
  290.       Exit Sub
  291.   Else
  292.     Text3.Text = GroupFormula
  293.   End If
  294. If SelectFormula = "" And GroupFormula = "" And NFormulas = 0 Then
  295.   MsgBox ("There are no formulas, selection formulas or group selection formulas to retrieve!")
  296. End If
  297. End Sub
  298. Sub FormCombo_Click ()
  299. 'Declarations
  300.  Dim Formula As String
  301.  Dim TextHandle1 As Integer, TextLength1 As Integer, NameHandle1 As Integer, NameLength1 As Integer
  302. 'Enable Set button for formulas
  303. Command7.Enabled = True
  304.     If PEGetNthFormula(JobNum, FormCombo.ListIndex, NameHandle1, NameLength1, TextHandle1, TextLength1) = False Then
  305.       RCode = GetErrorString(JobNum)
  306.       MsgBox "PEGetNthFormula Error #: " + Str(ErrorCode) + " - " + RCode
  307.     End If
  308.     Formula = String(TextLength1, " ")
  309.     If PEGetHandleString(TextHandle1, Formula, TextLength1) = False Then
  310.       'Handle Error
  311.       RCode = GetErrorString(JobNum)
  312.       MsgBox "PEGetHandleString Error #: " + Str(ErrorCode) + " - " + RCode
  313.     Else
  314.       Text2.Text = Formula
  315.     End If
  316.     FormulaText.Text = FormCombo.Text
  317. End Sub
  318. Sub MenuFileExit_Click ()
  319.  Unload Me
  320. End Sub
  321.