Solved

Determine Enabled Status for Cut, Copy, Paste Toolbar Items

Posted on 2008-06-22
5
223 Views
Last Modified: 2011-10-19
Hello,
I have a toolbar that contains a cut, copy, and paste button and I need them to enable/disable accordingly with my TextStandard textbox.  So for example, if my cursor is in the TextStandard textbox (nothing's selected) and I have text within my clipboard, the cut and copy buttons should become disabled and the paste button should be enabled.  Now if i select atleast a character of text, all 3 buttons should be enabled.  If I don't have anything within my clipboard, the Paste button should be disabled. How do i accomplish this? (exactly like MS word)
0
Comment
Question by:Gunit2507
  • 2
5 Comments
 
LVL 6

Expert Comment

by:psychic_zero
Comment Utility
What version of VB you are using?
0
 

Author Comment

by:Gunit2507
Comment Utility
VB6
0
 
LVL 6

Accepted Solution

by:
psychic_zero earned 500 total points
Comment Utility
Pls create a VB project based on the instruction I gave you in Word document. Then copy and paste this code in the project. Hope this can help you...
Private Sub Command1_Click()

Clipboard.Clear

Toolbar1.Buttons(3).Enabled = False

End Sub
 

Private Sub Form_Load()

Toolbar1.Buttons(1).Enabled = False

Toolbar1.Buttons(2).Enabled = False
 

If Clipboard.GetText = "" Then

    Toolbar1.Buttons(3).Enabled = False

Else

    Toolbar1.Buttons(3).Enabled = True

End If
 

End Sub
 

Private Sub Text1_Click()

If Text1.SelLength > 0 Then

    Toolbar1.Buttons(1).Enabled = True

    Toolbar1.Buttons(2).Enabled = True

Else

    Toolbar1.Buttons(1).Enabled = False

    Toolbar1.Buttons(2).Enabled = False

End If

End Sub
 

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)

If Text1.SelLength > 0 Then

    Toolbar1.Buttons(1).Enabled = True

    Toolbar1.Buttons(2).Enabled = True

Else

    Toolbar1.Buttons(1).Enabled = False

    Toolbar1.Buttons(2).Enabled = False

End If

End Sub
 

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

   Select Case Button.Key

   Case Is = "Cut"

      Clipboard.SetText Text1.SelText

      Text1.SelText = ""

      Toolbar1.Buttons(3).Enabled = True

   Case Is = "Copy"

      Clipboard.SetText Text1.SelText

      Toolbar1.Buttons(3).Enabled = True

   Case Is = "Paste"

        Text1.SelText = Clipboard.GetText

   End Select

End Sub

Open in new window

form-instruction.doc
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now