First you need to create a project file with the following control
lblTest (Label)
txtEdit (Text Box)
and the code will look like below:
Code:Option Explicit Private Sub lblTest_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'only apply to mouse's left button If Button = vbLeftButton Then txtEdit.Top = lblTest.Top txtEdit.Left = lblTest.Left txtEdit.Height = lblTest.Height txtEdit.Width = lblTest.Width txtEdit.Text = lblTest.Caption txtEdit.Visible = True If lblTest.Caption <> "" Then txtEdit.SelStart = Len(lblTest.Caption) txtEdit.SetFocus End If End If End Sub Private Sub txtEdit_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then lblTest.Caption = txtEdit.Text txtEdit.Visible = False End If End Sub Private Sub txtEdit_LostFocus() txtEdit.Visible = False End Sub




Reply With Quote