Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 156547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:20:49+00:00 2026-05-11T10:20:49+00:00

I have a decent sized set of data that needs to be stored in

  • 0

I have a decent sized set of data that needs to be stored in an active record. In order to prepopulate the form fields on the page, I have already written the following code:

Device device = new Device(DeviceID); // device is simply the active record  txtDeviceName.Text = device.Name; txtNotes.Text = device.Notes; txtHostName.Text = device.Hostname; txtAssetTag.Text = device.AssetTag; txtSerialNumber.Text = device.SerialNumber; // snip... the list goes on! 

Is there some sort of the method (built-in functionality, macro, etc.) that I could use to swap each side of the expression such that the data is saved into the active record as opposed to read from it in order to perform a database insert? For example, after highlighting the above code and running the macro, it would become:

device.DeviceName = txtDeviceName.Text; device.Notes = txtNotes.Text; device.Hostname = txtHostName.Text; device.AssetTag = txtAssetTag.Text; device.SerialNumber = txtSerialNumber.Text; // snip again... 

Since the number of columns in the database that this active record encapsulates is rather large, it seems like most of this typing could be avoided with a simple automated process.

Obviously this wouldn’t work 100% because sometimes there would have to be type conversions (e.g. int to string) but for the most part I think this would save a lot of time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:20:49+00:00Added an answer on May 11, 2026 at 10:20 am

    Here is a macro that will do it:

    Imports System Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics Imports System.Text.RegularExpressions  Public Module Helpers     Sub SwapAssignment()         If (Not IsNothing(DTE.ActiveDocument)) Then             Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection, TextSelection)             selection.Text = Regex.Replace(selection.Text, '([^\s]*)\s*=\s*([^\s]*);', '$2 = $1;')         End If     End Sub End Module 

    Basically it takes the selected text (either one line or as many lines as you select) and uses a regular expression to swap the values. Not pretty but then macros never are.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a decent sized chunk of .NET code that now needs to be
I am working with a decent sized set of data relating to objects on
I have noticed that some WPF controls have some decent effects available to them
I have a weekly script that moves data from our live database and puts
We have a decent sized MVC project running well at the moment, i've started
We have a decent-sized development team with a few concurrent projects being developed on
If I have a decent size asp.net page open in Source view, and hold
I have a pretty decent sized program (~1000 loc) . When i run the
I'm fairly new to Dreamweaver and am testing the trial software. I have decent
I don't have any experience writing drivers, but have a decent grasp on architecture,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.