473,804 Members | 3,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net macros - how to fetch string in clipboard into a string variable

Hi all,

I'm finally sick and tired of manually generating get/set properties for
each private variable in a class so I'm trying to create a macro to do it.

I'm stuck because I can't figure out how to get a string that is in the
clipboard into a variable in the macro. I tried this:

Dim x as string = DTE.ActiveDocum ent.Selection.P aste() thinking it would
"paste" the clipboard into the string variable X, but it just pasted the
string into the document.

Can somebody give me a code example that transfers the string in the
clipboard into a variable in the macro?

Thanks,
John
Nov 21 '05 #1
4 4221

JohnR wrote:
Hi all,

I'm finally sick and tired of manually generating get/set properties for each private variable in a class so I'm trying to create a macro to do it.
I'm stuck because I can't figure out how to get a string that is in the clipboard into a variable in the macro. I tried this:

Dim x as string = DTE.ActiveDocum ent.Selection.P aste() thinking it would "paste" the clipboard into the string variable X, but it just pasted the string into the document.

Can somebody give me a code example that transfers the string in the
clipboard into a variable in the macro?

Thanks,
John


this defeats the purpose of having private member variables -- the idea
is to perform some sort of testing in the "set". if this is not
necessary, then make the variable public and be done with it...

Nov 21 '05 #2
Look up 'Clipboard' & 'Text'. You will then find an example in the built in
MSDN Documentation

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #3
I'm sorry, I must not have made my question clear.

When I'm actually writing the code in the IDE and I type "private _myvar as
string" I want to have a macro automatically generate
the Property get-set code. This question has nothing at all to do about
actually running the program. One way of doing this involves
copying the "private _myvar as string" line into the clipboard,
repositioning the cursor to where you want the property code to be, and
then running the macro that will copy the string in the clipboard into a
string variable and then process it... That is the genesis of my question
of "how do you get a string from the clipboard into a string variable in a
macro?"

John

"stand__sur e" <st*********@ho tmail.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...

JohnR wrote:
Hi all,

I'm finally sick and tired of manually generating get/set

properties for
each private variable in a class so I'm trying to create a macro to

do it.

I'm stuck because I can't figure out how to get a string that is in

the
clipboard into a variable in the macro. I tried this:

Dim x as string = DTE.ActiveDocum ent.Selection.P aste() thinking it

would
"paste" the clipboard into the string variable X, but it just pasted

the
string into the document.

Can somebody give me a code example that transfers the string in the
clipboard into a variable in the macro?

Thanks,
John


this defeats the purpose of having private member variables -- the idea
is to perform some sort of testing in the "set". if this is not
necessary, then make the variable public and be done with it...

Nov 21 '05 #4
Here is a couple of macros that I use. To use them, you would declare
your private variables like this: Private m_SomeName As Integer. It
will take the name of the property excluding the m_ from the front. If
you don't use m_ you will have to change the InsertProperty method to
handle whatever convention you use. The ReservedWords array is for
property names that are reserved words. I only show a few in this
post, but you can add any reserved word to this array and the macro
will put it in square brackets as needed.

Friend ReservedWords() As String = {"ASSEMBLY", "CLASS", "FORM"}

Public Sub PropertyFromVar ()
Dim ts As TextSelection = CType(DTE.Activ eWindow.Selecti on,
TextSelection)
Dim m_PropertyList( ts.TextRanges.C ount - 2) As String
Dim m_Index As Integer
Dim start As EditPoint = ts.TopPoint.Cre ateEditPoint()
Dim endpt As TextPoint = ts.BottomPoint
Dim sb As New StringBuilder

'Make these upper case
Try
Do While (start.LessThan (endpt))
m_PropertyList( m_Index) =
start.GetText(s tart.LineLength ).Trim.Replace( "New", "").Replace("() ",
"")
start.LineDown( )
start.StartOfLi ne()
m_Index += 1
Loop
Catch ex As System.Exceptio n
Debug.WriteLine (ex)
End Try

Dim cnt As Integer = m_Index

For m_Index = 0 To m_PropertyList. GetUpperBound(0 )
sb.Append(Inser tProperty(m_Pro pertyList(m_Ind ex)))
Next
ts.MoveToPoint( ts.ActivePoint. CodeElement(vsC MElement.vsCMEl ementClass).Get EndPoint(vsCMPa rt.vsCMPartWhol e))
ts.LineUp()
ts.EndOfLine()
ts.NewLine()
ts.NewLine()

ts.Insert(sb.To String)

DTE.ExecuteComm and("Edit.Forma tDocument")

End Sub

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3234
by: Agent Mulder | last post by:
My funky new compiler does not understand string, but it does understand String, so that this program gives the expected result: #include<iostream> #include<string> int main() { String a="Hello World"; cout<<a<<endl;
0
5380
by: Hessam | last post by:
Hello, I am designing a .net custom control in VS.net 7.1 and my control exposes an array of strings which are supposed to be the items to show. To do this have declared a private string variable and a public property which returns it. string options = new string; public string Options {
4
11899
by: J. Oliver | last post by:
I am attempting to copy a portion of a string into another string. Say I have "abcdef" in string 'a' and want to copy only "bcd" into a new string 'b'. The following function came to mind: public string GetText(string a, int start, int end) { int i; string b;
6
12766
by: Raed Sawalha | last post by:
i have the following case a MyClass class has method with 2 arguments as void SetProp(string varname,string varvalue); in MyClass i have following members string stdname,stddate,stdbirth,stdloc from other class i created object from MyClass ,
6
17814
by: Frank King | last post by:
Hi, I am looking for a hash function to map string to string in VB. Could somebody give me some informtion? Thank you very much. fk
7
22514
by: Bruce One | last post by:
What is the difference between String and string in C#? What can u do with string that you cant do with String, vice versa?
1
1382
by: jrgoncal | last post by:
Hi, basically what i want to do is use a string as a variable, so instead of doing this: $ar = new array("Dog","Cat","Bear","Dear","Postal Worker"); $var_1 = $ar; $var_2 = $ar; $var_3 = $ar; $var_4 = $ar; $var_5 = $ar;
5
16800
by: rohdej | last post by:
Hello - I have been all over the web and found a few posts that are somewhat related to what I'm trying to do, but none that provided me a concise answer. I want to prompt the user to input the name of a structure in my program. I want to then be able to manipulate that structure in my program. For example: #include <iostream>
7
1591
by: =?Utf-8?B?R3JlZw==?= | last post by:
I've noticed two different "String" variable declarations to choose from. One uses an upper case "S" and the other uses a lower case "s". The upper case appears in a light green color, while the lower case appears as blue. If I go to the the variable's definition the same definition appears for each, which suggests to me these must be the same type. Is there actually a different meaning for each type and what would this difference be?...
6
4466
by: vijayarl | last post by:
Hi Everyone, i need to add a string in between the filename.so that new file will have the required filename. what am doing is reading the files from the directory & extract only the filename and then pass this failename to create new file. now what i need is instead of just passing filename, i need to add some string to this filename & then pass the filename to create a new file.
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.