Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

mouse selection in VB3.0

Posted on 1998-06-07
4
Medium Priority
?
173 Views
Last Modified: 2010-05-03
I need to select a section using a mouse from a body of text  in a textbox.I want to be able to use this selected text later in the program for other purposes. I am using VB3.0/Win95 can somebody help me?
0
Comment
Question by:sharanya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:sharanya
ID: 1462747
Edited text of question
0
 

Accepted Solution

by:
loguea earned 300 total points
ID: 1462748
You can obtain the selected text by using the Textbox SelText property and it can be copied to the clipboard as follows:

Clipboard.SetText = Text1.SelText

You can then later retrieve the text from the clipboard with:

Clipboard.GetText

0
 

Author Comment

by:sharanya
ID: 1462749
Need clarification:
when i type Clipboard.SetText = Text1.SelText in the code for textbox, i get "Need expression" error.Why?
I have defined a string variable , selection = Clipboard.GetText,why does it expect a ()for GetText?
My books dont talk about this, please clarify.
0
 

Expert Comment

by:loguea
ID: 1462750
Sorry about that, the SetText sample code should say:

Clipboard.SetText Text1.SelText
or
Call Clipboard.SetText(Text1.SelText)

This is because SetText is a method of the Clipboard object as opposed to a property.
And as you point out the GetText sample should really have parentheses as well ie.

yourVar = Clipboard.GetText()

Once again this is because GetText is a method of the clipboard object not a property.

As a simple example follow these steps:

Step 1) Create a new project (Project1 is created by default)

Step 2) Add two textboxes to the form these will be called Text1 and Text2 by default and the form is called Form1 by default.

Step 3) Copy the following code into the code window for Form1

Private Sub Text1_MouseUp(Button As Integer,Shift As Integer,X As Single,Y As Single)
    If Text1.SelText <> "" Then
        Clipboard.SetText Text1.SelText
    End If
   
    Text2.Text = Clipboard.GetText()
End Sub

Step 4) Run the project and use the mouse to select some of the text in Text1. You'll notice that when the mouse is released if there is any text selected then the text property of Text2 is set to the selected text from Text1.

Hope this helps.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

609 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