home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / crwdemo / setformu.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-05  |  5.9 KB  |  191 lines

  1. VERSION 2.00
  2. Begin Form SetFormula 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Formulas"
  5.    ClientHeight    =   3780
  6.    ClientLeft      =   1410
  7.    ClientTop       =   1935
  8.    ClientWidth     =   7800
  9.    Height          =   4470
  10.    Left            =   1350
  11.    LinkTopic       =   "Form3"
  12.    ScaleHeight     =   4428.806
  13.    ScaleMode       =   0  'User
  14.    ScaleWidth      =   7800
  15.    Top             =   1305
  16.    Width           =   7920
  17.    Begin TextBox Text5 
  18.       Height          =   375
  19.       Left            =   2520
  20.       TabIndex        =   11
  21.       Top             =   240
  22.       Width           =   2655
  23.    End
  24.    Begin SSPanel StatusBar 
  25.       Alignment       =   1  'Left Justify - MIDDLE
  26.       BorderWidth     =   1
  27.       Height          =   405
  28.       Left            =   0
  29.       TabIndex        =   2
  30.       Top             =   3390
  31.       Width           =   7815
  32.    End
  33.    Begin TextBox Text4 
  34.       Height          =   375
  35.       Left            =   2520
  36.       TabIndex        =   3
  37.       Top             =   2190
  38.       Width           =   5055
  39.    End
  40.    Begin TextBox Text3 
  41.       Height          =   375
  42.       Left            =   2520
  43.       TabIndex        =   9
  44.       Top             =   1680
  45.       Width           =   5055
  46.    End
  47.    Begin CommandButton Command5 
  48.       Caption         =   "Set Selection Formula"
  49.       Height          =   375
  50.       Left            =   360
  51.       TabIndex        =   8
  52.       Top             =   2160
  53.       Width           =   2055
  54.    End
  55.    Begin CommandButton Command4 
  56.       Caption         =   "Get Selection Formula"
  57.       Height          =   375
  58.       Left            =   360
  59.       TabIndex        =   7
  60.       Top             =   1680
  61.       Width           =   2055
  62.    End
  63.    Begin CommandButton Command3 
  64.       Caption         =   "Set Formula"
  65.       Height          =   375
  66.       Left            =   360
  67.       TabIndex        =   6
  68.       Top             =   1200
  69.       Width           =   2055
  70.    End
  71.    Begin CommandButton Command2 
  72.       Caption         =   "Close"
  73.       Height          =   375
  74.       Left            =   360
  75.       TabIndex        =   5
  76.       Top             =   2640
  77.       Width           =   2055
  78.    End
  79.    Begin CommandButton Command1 
  80.       Caption         =   "Get Formula"
  81.       Height          =   375
  82.       Left            =   360
  83.       TabIndex        =   4
  84.       Top             =   750
  85.       Width           =   2055
  86.    End
  87.    Begin TextBox Text2 
  88.       Height          =   405
  89.       Left            =   2520
  90.       MultiLine       =   -1  'True
  91.       TabIndex        =   1
  92.       Top             =   1200
  93.       Width           =   5055
  94.    End
  95.    Begin TextBox Text1 
  96.       Height          =   405
  97.       Left            =   2520
  98.       TabIndex        =   0
  99.       Top             =   720
  100.       Width           =   5055
  101.    End
  102.    Begin Label Label1 
  103.       BackColor       =   &H00C0C0C0&
  104.       Caption         =   "Enter Formula Name"
  105.       Height          =   255
  106.       Left            =   360
  107.       TabIndex        =   10
  108.       Top             =   240
  109.       Width           =   2055
  110.    End
  111.    Begin Menu MenuFile 
  112.       Caption         =   "&File"
  113.       Begin Menu MenuFileExit 
  114.          Caption         =   "&Exit"
  115.       End
  116.    End
  117. Dim FormulaName As String
  118. Dim SelectFormula As String
  119. Sub Command1_Click ()
  120.   Dim FormulaText As String
  121.   Dim Formula As String
  122.   Dim TextHandle As Integer, TextLength As Integer
  123.   FormulaName = Text5.Text + Chr$(0)
  124.   If Text5.Text = "" Then
  125.     MsgBox "There is no formula to retrieve. Please enter a formula name."
  126.   Else
  127.     If PEGetFormula(JobNum, FormulaName, TextHandle, TextLength) = False Then
  128.       RCode = GetErrorString(JobNum)
  129.       MsgBox "PEGetFormula Error #: " + Str(ErrorCode) + " - " + RCode
  130.     End If
  131.     ' Allocate memory for string
  132.     Formula = String(TextLength, " ")
  133.     If PEGetHandleString(TextHandle, Formula, TextLength) = False Then
  134.      ' Handle error
  135.       RCode = GetErrorString(JobNum)
  136.       MsgBox "PEGetHandleString Error #: " + Str(ErrorCode) + " - " + RCode
  137.     Else
  138.       Text1.Text = Formula
  139.       SETFORMULA!StatusBar.Caption = "The formula " + Text5.Text + " has been retrieved as ---> " + Text1.Text
  140.     End If
  141.   End If
  142. End Sub
  143. Sub Command2_Click ()
  144.  Unload Me
  145. End Sub
  146. Sub Command3_Click ()
  147. 'Set formula to pass to crystal Reports
  148. 'Notice that the string pointer must be embedded in quotes
  149. 'the formula name does not have quote surrounding it and does not include
  150. 'the @ sign as shown in Crystal Reports
  151.   FormName = Text5.Text + Chr(0)
  152.   If Text5.Text = "" Then
  153.     MsgBox "There is no formula to retrieve. Please enter a formula name."
  154.   Else
  155.     If Text2.Text = "" Then
  156.       MsgBox "You have to enter a formula before you can set one."
  157.     Else
  158.       If PESetFormula(JobNum, FormName, Text2.Text) = False Then
  159.        MsgBox ("Setting the Formula has failed")
  160.       Else
  161.         SETFORMULA!StatusBar.Caption = "The formula " + Text5.Text + " has been set to --->" + Text2.Text
  162.       End If
  163.     End If
  164.   End If
  165. End Sub
  166. Sub Command4_Click ()
  167.   Dim SelectFormula As String
  168.   Dim TextHandle As Integer, TextLength As Integer
  169.   If PEGetSelectionFormula(JobNum, TextHandle, TextLength) = False Then
  170.      MsgBox ("Cannnot get Selection Formula")
  171.   End If
  172.   ' Allocate memory for string
  173.   SelectFormula = String(TextLength, " ")
  174.   If PEGetHandleString(TextHandle, SelectFormula, TextLength) = False Then
  175.     MsgBox ("Cannot get Handle String")
  176.   Else
  177.     Text3.Text = SelectFormula
  178.     SETFORMULA!StatusBar.Caption = "The Selection formula has been retrieved"
  179.   End If
  180. End Sub
  181. Sub Command5_Click ()
  182.   If PESetSelectionFormula(JobNum, Text4.Text) = False Then
  183.     MsgBox ("Cannot Set Selection Formula")
  184.   Else
  185.     SETFORMULA!StatusBar.Caption = "The Selection formula has been Set"
  186.   End If
  187. End Sub
  188. Sub MenuFileExit_Click ()
  189.  Unload Me
  190. End Sub
  191.