VERSION 5.00 Begin VB.Form FrmAddPartition BorderStyle = 3 'Fixed Dialog Caption = "Adding Partition " ClientHeight = 1575 ClientLeft = 45 ClientTop = 330 ClientWidth = 3360 ControlBox = 0 'False LinkTopic = "FrmAddPartition" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 1575 ScaleWidth = 3360 ShowInTaskbar = 0 'False StartUpPosition = 2 'CenterScreen Begin VB.CommandButton cmdCancel Caption = "&Cancel" Height = 360 Index = 2 Left = 2280 TabIndex = 4 Top = 1100 Width = 975 End Begin VB.CommandButton cmdHelp Caption = "&Help" Height = 360 Index = 1 Left = 1200 TabIndex = 3 Top = 1100 Width = 975 End Begin VB.CommandButton cmdUpdate Caption = "&Update" Height = 360 Index = 0 Left = 120 TabIndex = 2 Top = 1100 Width = 975 End Begin VB.Frame Frame1 Caption = "Enter a friendly name for this partition:" Height = 850 Left = 120 TabIndex = 0 Top = 120 Width = 3135 Begin VB.TextBox txtName Height = 300 Left = 240 TabIndex = 1 Top = 340 Width = 2655 End End End Attribute VB_Name = "FrmAddPartition" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub cmdCancel_Click(Index As Integer) 'Flag as cancelled glbtmpString = "" 'Close the form down Unload Me End Sub Private Sub cmdUpdate_Click(Index As Integer) If (Len(txtName.Text) = 0) Then MsgBox "The name must be between 1 and 10 characters", vbExclamation + vbSystemModal + vbOKOnly, "Update Error" 'Minor detail, but nice - Return the focus to the text box txtName.SetFocus Else glbtmpString = txtName.Text Unload Me End If End Sub Private Sub Form_Load() txtName.MaxLength = 10 txtName.Text = glbtmpString txtName.SelLength = Len(txtName.Text) End Sub Private Sub txtName_KeyPress(KeyAscii As Integer) Dim intLeft As Integer Dim intSelStart As Integer If (KeyAscii = 13) Then cmdUpdate_Click (0) ElseIf (txtName.SelLength > 0) Then intSelStart = txtName.SelStart intLeft = Len(txtName.Text) - (intSelStart + txtName.SelLength) txtName.Text = Left$(txtName.Text, txtName.SelStart) & Right$(txtName.Text, intLeft) txtName.SelStart = intSelStart ElseIf (Len(txtName.Text) > 9) And (KeyAscii > 31) Then KeyAscii = 0 End If End Sub