home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / Code / ch43 / frmAddIn.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-07-13  |  8.0 KB  |  247 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAddIn 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Add New Property"
  5.    ClientHeight    =   4230
  6.    ClientLeft      =   2175
  7.    ClientTop       =   1935
  8.    ClientWidth     =   5490
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   4230
  13.    ScaleWidth      =   5490
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CheckBox chkObject 
  17.       Caption         =   "It is an &Object"
  18.       Height          =   255
  19.       Left            =   120
  20.       TabIndex        =   6
  21.       Top             =   2280
  22.       Width           =   2175
  23.    End
  24.    Begin VB.Frame Frame2 
  25.       Caption         =   "Scope"
  26.       Height          =   1455
  27.       Left            =   2040
  28.       TabIndex        =   16
  29.       Top             =   2640
  30.       Width           =   1935
  31.       Begin VB.OptionButton optScope 
  32.          Caption         =   "&Friend"
  33.          Height          =   255
  34.          Index           =   2
  35.          Left            =   240
  36.          TabIndex        =   12
  37.          Top             =   1080
  38.          Width           =   1095
  39.       End
  40.       Begin VB.OptionButton optScope 
  41.          Caption         =   "P&ublic"
  42.          Height          =   255
  43.          Index           =   1
  44.          Left            =   240
  45.          TabIndex        =   11
  46.          Top             =   720
  47.          Value           =   -1  'True
  48.          Width           =   1095
  49.       End
  50.       Begin VB.OptionButton optScope 
  51.          Caption         =   "&Private"
  52.          Height          =   255
  53.          Index           =   0
  54.          Left            =   240
  55.          TabIndex        =   10
  56.          Top             =   360
  57.          Width           =   1095
  58.       End
  59.    End
  60.    Begin VB.TextBox txtVariable 
  61.       Height          =   315
  62.       Left            =   120
  63.       TabIndex        =   3
  64.       Top             =   1200
  65.       Width           =   3855
  66.    End
  67.    Begin VB.Frame Frame1 
  68.       Caption         =   "Property Procedures "
  69.       Height          =   1455
  70.       Left            =   120
  71.       TabIndex        =   15
  72.       Top             =   2640
  73.       Width           =   1815
  74.       Begin VB.CheckBox chkSet 
  75.          Caption         =   "Property &Set"
  76.          Enabled         =   0   'False
  77.          Height          =   255
  78.          Left            =   240
  79.          TabIndex        =   9
  80.          Top             =   1080
  81.          Width           =   1455
  82.       End
  83.       Begin VB.CheckBox chkLet 
  84.          Caption         =   "Property &Let"
  85.          Height          =   255
  86.          Left            =   240
  87.          TabIndex        =   8
  88.          Top             =   720
  89.          Value           =   1  'Checked
  90.          Width           =   1455
  91.       End
  92.       Begin VB.CheckBox chkGet 
  93.          Caption         =   "Property &Get"
  94.          Height          =   255
  95.          Left            =   240
  96.          TabIndex        =   7
  97.          Top             =   360
  98.          Value           =   1  'Checked
  99.          Width           =   1455
  100.       End
  101.    End
  102.    Begin VB.ComboBox cboDataType 
  103.       Height          =   315
  104.       ItemData        =   "frmAddIn.frx":0000
  105.       Left            =   120
  106.       List            =   "frmAddIn.frx":0025
  107.       TabIndex        =   5
  108.       Top             =   1920
  109.       Width           =   3855
  110.    End
  111.    Begin VB.TextBox txtName 
  112.       Height          =   315
  113.       Left            =   120
  114.       TabIndex        =   1
  115.       Top             =   480
  116.       Width           =   3855
  117.    End
  118.    Begin VB.CommandButton cmdCancel 
  119.       Cancel          =   -1  'True
  120.       Caption         =   "Cancel"
  121.       Height          =   375
  122.       Left            =   4200
  123.       TabIndex        =   14
  124.       Top             =   3720
  125.       Width           =   1215
  126.    End
  127.    Begin VB.CommandButton cmdCopy 
  128.       Caption         =   "&Copy"
  129.       Height          =   375
  130.       Left            =   4200
  131.       TabIndex        =   13
  132.       Top             =   3240
  133.       Width           =   1215
  134.    End
  135.    Begin VB.Label Label1 
  136.       Caption         =   "&Member Variable"
  137.       Height          =   255
  138.       Index           =   2
  139.       Left            =   120
  140.       TabIndex        =   2
  141.       Top             =   960
  142.       Width           =   1455
  143.    End
  144.    Begin VB.Label Label1 
  145.       Caption         =   "&Data Type"
  146.       Height          =   255
  147.       Index           =   1
  148.       Left            =   120
  149.       TabIndex        =   4
  150.       Top             =   1680
  151.       Width           =   1455
  152.    End
  153.    Begin VB.Label Label1 
  154.       Caption         =   "&Name"
  155.       Height          =   255
  156.       Index           =   0
  157.       Left            =   120
  158.       TabIndex        =   0
  159.       Top             =   240
  160.       Width           =   1455
  161.    End
  162. Attribute VB_Name = "frmAddIn"
  163. Attribute VB_GlobalNameSpace = False
  164. Attribute VB_Creatable = False
  165. Attribute VB_PredeclaredId = True
  166. Attribute VB_Exposed = False
  167. ' this is the standard prefix used to build Member variable names
  168. Const DEFAULT_PREFIX As String = "m_"
  169. ' this properties are filled by the Connect class
  170. Public Connect As Connect
  171. Public VBInstance As VBIDE.VBE
  172. Private Sub Form_Load()
  173.     ' restore defaults
  174.     txtVariable = DEFAULT_PREFIX
  175.     cboDataType.Text = "String"
  176. End Sub
  177. Private Sub txtName_Change()
  178.     ' build the name of the member variable
  179.     txtVariable.Text = DEFAULT_PREFIX & txtName.Text
  180. End Sub
  181. Private Sub cboDataType_Click()
  182.     ' delegate to the Change event
  183.     Call cboDataType_Change
  184. End Sub
  185. Private Sub cboDataType_Change()
  186.     ' enable or disable the "Property Set" checkbox according
  187.     ' to which data type has been selected
  188.     Select Case LCase$(cboDataType.Text)
  189.         Case "integer", "long", "single", "double", "currency", "string", "date", "byte", "boolean"
  190.             chkObject.Enabled = False
  191.         Case "object"
  192.             chkObject.Enabled = True
  193.             chkObject.Value = vbChecked
  194.         Case Else
  195.             chkObject.Enabled = True
  196.     End Select
  197. End Sub
  198. Private Sub chkObject_Click()
  199.     chkSet.Enabled = chkObject.Value
  200. End Sub
  201. Private Sub cmdCopy_Click()
  202.     Clipboard.Clear
  203.     Clipboard.setText GeneratedCode
  204.     Unload Me
  205. End Sub
  206. Private Sub cmdCancel_Click()
  207.     Unload Me
  208. End Sub
  209. Private Function GeneratedCode() As String
  210.     Dim codeText As String
  211.     Dim scopeText As String
  212.     Dim setText As String
  213.     ' retrieve the scope
  214.     If optScope(0).Value Then
  215.         scopeText = "Private "
  216.     ElseIf optScope(1).Value Then
  217.         scopeText = "Public "
  218.     Else
  219.         scopeText = "Friend "
  220.     End If
  221.     ' should we use "set" when assigning?
  222.     If chkObject.Enabled And chkObject.Value = vbChecked Then
  223.         setText = "Set "
  224.     End If
  225.     ' create the declaration of the member variable
  226.     codeText = "Private " & txtVariable & " As " & cboDataType & vbCrLf & vbCrLf
  227.     ' add the Property Get code, if requested
  228.     If chkGet.Value Then
  229.         codeText = codeText & scopeText & "Property Get " & txtName & "() As " & cboDataType.Text & vbCrLf _
  230.             & vbTab & setText & txtName & " = " & txtVariable & vbCrLf _
  231.             & "End Property" & vbCrLf & vbCrLf
  232.     End If
  233.     ' add the Property Let code, if requested
  234.     If chkLet.Value Then
  235.         codeText = codeText & scopeText & "Property Let " & txtName & "(newValue As " & cboDataType.Text & ")" & vbCrLf _
  236.             & vbTab & txtVariable & " = newValue" & vbCrLf _
  237.             & "End Property" & vbCrLf & vbCrLf
  238.     End If
  239.     ' add the Property Let code, if requested
  240.     If setText <> "" And chkSet.Value Then
  241.         codeText = codeText & scopeText & "Property Set " & txtName & "(newValue As " & cboDataType.Text & ")" & vbCrLf _
  242.             & vbTab & setText & txtVariable & " = newValue" & vbCrLf _
  243.             & "End Property" & vbCrLf & vbCrLf
  244.     End If
  245.     GeneratedCode = codeText
  246. End Function
  247.