Public Variables - Copying / Pasting Some Lines From Another One
Jan 2, 2012I'm writing a new app and copying/pasting some lines from another one. In the new app, I get error when I use variables defined as public.
[Code]....
I'm writing a new app and copying/pasting some lines from another one. In the new app, I get error when I use variables defined as public.
[Code]....
I have a bunch of private variables I've typed out and I want to put all of my corresponding Public ReadOnly Properties in a bunch below them.Is there some way of copying ten lines of
Private _myVar As String
and pasting in ten sets of
Public Readonly Property MyVar As String
Get
Return _myVar[code]....
I'm currently copying the whole bunch of variable declarations, Find+Replacing Private _ into Public ReadOnly Property then going line-by-line expanding the definitions and writing return statements.how to avoid all this nonsense in the future, as I'm developing on a virtual terminal server, and the input lag on my little copy/paste/type operations on the code is driving me up the wall.
I have a form that I am creating to document information about computers that I build. I have created the basic layout, what I have is a group box that has many different controls in it (text boxes, combo boxes, additional group boxes etc) What I want to be able to do is have a button that will copy the group box (computer information) and all of its contents and then paste it below the first group box with all of the fields blank or in their default setting; and keep doing this for as many computers as I want to add. Each project I do has a different amount of computers on it so I want this form to be able to handle any amount of computers.
I can't seem to find much on what I want to do, any pointers, direction or idea's
I was able to do this with an excel spreadsheet but all I had to do was reference and select a cell range, scroll down and paste the new section in. This is my code from excell, just as an example of what I did then. But with VB I'm stumped on how to approach this.
Range("U3:AB11").Select
Range("U11").Activate
Application.CutCopyMode = False
[code]....
how do i prohibit a user from copying from and pasting to a textbox
View 5 RepliesI am trying to copy text from a standard rich text box on a button click. However, I only want the first 3575 characters to be copied to my second rich text box, and after the 3575 I want a further 8482 characters to be copied to my third.
View 2 RepliesIn VB 2008, I am trying to create an app that will copy a range of cells from one worksheet ("xlWS1") in the first workbook ("xlWB1") to another worksheet ("2") in a second workbook ("xlWB2"), starting in cell A1. I would like this to be activated by a button.Then, another button will copy the same cells from "xlWS1" to "xlWB2", worksheet "3", and so on for each subsequent button.
xlWB1/xlWS1 contains data in the cells that is updated from our data acquisition system once per second. (we perform jet engine testing). "xlWB2" sheets (6 of them) will contain the saved data from the "live" screen (xlWS1, came cell range) in the first WB. There are several different versions (filenames) of the second workbook, one for each engine model.Both workbooks should already be open, but I would also like the app to open them if they are not open already.
We have been using VBA macros to do this, but run into problems when someone saves the second (destination) workbook under a different filename. For some reason, if the filename of the Wb that is already open isn't the same as what's in the macro for that button, the macro's defined workbook is renamed in the macro. I am trying to get away from using the macros to keep this from happening, and to make an app that's "foolproof" so it is more reliable.
I already have an app that will open the proper workbooks. I may combine the two apps in the future. I can't find a solution for this. The VBA code is quite different and simple as far as opening, activating, copying, etc. Basically, I can't seem to find any self-explanatory "activate/copy/paste, etc." namespace in Vb 2008 like I used in the VBA macros.
I'm sure the solution is simple, but I just can't seem to find it in the MSDN library or the VS 2008 book I have. Everything in the book talks about accessing databases, which we don't use (yet). There's nothing concerning this issue with Excel 2003 workbooks/worksheets.
I'm working with the graphic designer in Visual Basic 2008 Express Edition. I tried to cut and paste a groupbox and the variables reverted to standard ones (CheckBox123 etc.), and when I tried to change them back to their proper names, I got an error message stating that this name is "already in use by another component". But this is nowhere to be seen anywhere in the "Form1.vb[Design]". How do I either get rid of these "hidden" variable names or reunite them with the groupbox they used to belong to?
View 8 RepliesSo I have this project for my internship at this company that is just screaming to be done with a script, but I don't know how to. I was given about 5,000 files to deal with. They are TRC files but can be opened in notepad to appear as follows:
[Code]...
I am creating a VB application in Visual Studio 2010 that installs some SQL stored procedures. These stored procedures are encrypted otherwise I would just supply my clients with .sql files to create the stored procedures.
The install script that creates the stored procedure is 1500 lines in length and has been formatted in the way VS 2010 requires multi-line literals to be in:
"First Line" & _
"Second Line" & _
"etc..."
[Code]....
I'm trying to copy a Range from Excel and Paste the information in powerpoint in either the HTML or the default format, however, I am having some difficulties. I am able to get the code to work for pasting the Range as an OLE Object but nothing else. The problem with doing this is that having the embedded excel documents in the powerpoint makes the file extremely large and unstable. I just need to be able to paste the information without the embedded information where it is editable (so, not as a bitmap or picture).
With ppt2Slide
Sheets(index2).Activate
Range("CP12:CT" & RangeIndex2).Copy
[code]....
I have a tab delimited text file as so :
name loan period loan amount
John 5 years 6000
Sarah 5 years 6000
Jane 1 month 100
I'm looking to copy the lines where "loan period" = "5 years" to where "loan period" = "1 month", in order to show the comparison. The new lines would be appended at the end of the resulting file. The ultimate end result I hope to achieve is this :
name loan period loan amount
John 5 years 6000
Sarah 5 years 6000
Jane 1 month 100
John 1 month 100
Sarah 1 month 100
I've been toying about this with Visual Basic .Net, and so far, this is what I've come up with
Dim strData As String
Dim i As Short
Dim strLine() As String
lngSize = 0
FileOpen(1, txtloanlistinput.Text, OpenMode.Input)
[Code] .....
I have 2 text files that are formatted in standard XML One of them contains some lines that need to be copied to the other. What i am trying to do is search through the first file until i see the string "<Segment" then copy all lines into a rich text box up until the string "<segment/>" I Then want to look through the other file until i find the string "<Jointfree/>" then copy the contents of the rich text box to underneath the Jointfree String I Also need to search the second file until i find the string "<Markers/>" and then paste some text into the line above the markers tag.
View 4 RepliesIm working on this webbrowser and i have fully integrated a working Proxy (it will use a proxy such as 100.00.00:0000)It will only change the proxy ip if you do the code:RefreshIESettings("100.00.00:0000")(That is a code i made, declared i mean)Anyway so heres what i wanna do:I want to have a richtextbox or something, with lines of proxy ips, such as this:
100.00.01:0000
100.00.02:0002
100.00.03:0003
[code]....
So i thought maybe if you convert that richtextbox text into a string, it might be easier?
I have been using VB a fair bit in the past developing a Access Database, recently I wanted to give my front end interface a bit more power so I have started learning VS 2010.
Anyways, I am still using Access for my databases and i am having a bit of trouble working with the data in VS 2010, what i would like is the following:
A way to form a string or integer from a SQL query (from a single field or multiple on that row) assuming the query will always return one row.
Then a way to write string or integer variables back in to db fields.
example:
Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|ItemRegisterDB.mdb")
Dim cmd As New OleDb.OleDbCommand With {.Connection = cn, .CommandText = "select * from tblItemregister where ItemID = 1"}
[Code]....
Example = ??? 'What would i need here to copy fields from that row to string?
I've created a 30 point wizard. Every step gathers between 1 and 3 variables. I've created a module and publicly declared the variables there. At the end of the wizard, one master form opens, gets all the variables, and displays them on one form. At this point calculations are run too which populates more variables. This works fine for one instance of the process.
the user may want to be running two instances of the wizard at once. Obviously, if the previous wizard is part complete and they start a new one, the variables are going to get crossed or replaced by the new wizard.Is there a way for the variables to be declared publicly but used in multiple instances?
I have a variable declared at Public on a form. But when I try to access it in a module I get an error that its not declared.
[code]...
I have a string on my main form called String1. When I open another form, I need access to this value. In the form I open, I have always done something like:Dim NewString as String = Main.String1
This has worked in the past. Well, I ended up renaming my forms (from Form1 to Main) in the property window and it now when I type the above code, it does not list Main as a form. Nothing that I renamed seems to exist now.
recently started converting our project from 1.1 to 2.0
It was fine with the following:
Public ghtAllAppMsgs As New Hashtable(300)
Now it is complaining to change to the following is this the right way:
Public ghtAllAppMsgs As New System.Collections.Hashtable(300)
This is under global.vb class file: here are the imports i already had in this file:
Imports Microsoft.Web.UI.WebControls
Imports Microsoft.Web.UI.WebControls.MultiPage
Imports System.Web
[Code]......
This seems basic but here's my problem. I am trying to build my connect string as a public variable that will connect to either an express version of SQL Server or a non-express version. The app.config defines it as being express or not and is modified to the user's choosing when it is deployed using the a firstRun routine.
The problem is that even though I'm modifying the value of the variable SQLexpress when the app is initiated which in turn should modify the value of the variable g_strConnectionString it doesn't. The value of g_strConnectionString will always take on the initial value of SQLexpress. I know I can define 2 separate variables for the connection string but I'd prefer not to have to change all of the references throughout each of the various programs in this system as they all have the same issue.
So in the following load event I've traced it and when it sets globals.SQLexpress = "", I then look at the value of g_strConnectionString and it still contains "SQLEXPRESS". It seems I need to somehow force vb to refresh this variable after it's been changed.
[Code]...
I am a little new to .NET Developing, and have learned a great deal recently, but I'm stuck with something. I come from an ASP Background, I'm trying to subtract 2 variables, but they don't seem to 'see' one another.
[Code]...
I have a MDI application and a very complicated class there which populates its properties from a dataset derived from an external database. Each form, including child forms have to be able to access that class and use its properties thorughout the whole session.I don't know where to 'preserve' these property values within the application. I kmow many books etc. suggest not to use public variables but I really can't find a way to solve this other than to use a public variable (which is a list(of my custom class) in this case.
I have a separate class called PublicItems.vb and declared there my public variable as
Public Shared secuniverse As List(Of myCustomClass)Is there something wrong with the syntax because if I try to use the variable secuniverse in my main application class, I get the following exception:'sectoruniverse' is not declared. It may be inaccessible due to its protection level.
I am using this example I found to learn how to load class files and access variables through them. This is in a file called Class1.vb in the App_Code folder (this is not an app project):
Imports Microsoft.VisualBasic
Public Class my_class
Public Shared Sub my_sub()
[Code]....
How could I access the vartest variable without using a session, since if this is accessed by multiple functions at the same time the variable can be overwritten I assume. Is it possible to go the other way, where a variable is sent to a class file?
I have created a public shared subroutine in a class file in asp.net 2 (vb.net) web site app_folder.The subroutine retrives some values from a sql database via an sql query and assigns the datareader field values to several variables The problem is I can't seem to assign the variables from the subroutine to the variables and textbox controls in the asp.net page I am calling the subroutine from. The textbox text value just appear blank.By the way, if I response.write the variables in the subroutine they appear populated by the sql data reader.
View 9 RepliesI am currently working on a project of "interpreting" C# into VB. The project involves adding images to a database, retrieving images from the database and presenting them in thumbnails. Right now I have the following Public Class with the Variable that needs to be assigned:
VB:
Imports System.Data
Imports System.Drawing
Imports System.IO
[code]....
When and why do you declare variables in the Public Class Form1 section?
View 1 RepliesI'd like to get a more refined programming style and I was wondering if any of you might give me a hand...(How to declare public variables, constants, functions...in a proper way),is there any useful link or pdf document I could have a look in order to improve my style?
View 5 Repliesgive me a good resource that explains the difference between a Private, Public, Shared Functions/Sub/Variables? I normally use Public for Subs/Functions inside of Modules I call from other parts of the program. But I'd like to get more of an understanding of how and when to use them. I want as little as impact to a system that is running my programs as possible, so i guess the key here is I'm trying to just get more proficient in my coding.
View 8 RepliesI have the following code:
Public Function StoreFields()
Dim Lockbox, Cash_Deposit_Date, Batch_Number
Lockbox = Xdocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:tbl_GC100/@Lockbox").Text
[code].....
I have tested the variables in the Functions and the are correct.
In vb.net, you can address a public variable from another form using the form name along with the variable.
form2.show
form2.k = 3
However, if you use a form variable to show an instance of the form, you must use that variable name to address the public variable. Two instances of the same form are displayed in the following example. The public variable k is assigned a value of 3 only in the first instance of the form, the one from form2.show. frm.k can be used to assign a value to the other form.
dim frm as new form2
form2.show
frm.show
form2.k = 3
Assuming only one instance of the form is shown in the application, is it reliable to address a public variable using the form name (form2.k), or is it better to show the form with a form variable and use that to refer to the instance of the form (frm.k)? Would the same answer apply to a property as well as a public variable?
I have these list of RS-232 strings declared in my public class
Public Class TouchInterface
Dim WatchTVbtnCmd As String = "rs232command1"
Dim VolUpbtnCmd As String = "rs232command2"
Dim VolDownbtnCmd As String = "rs232command3"
Dim SystemOffbtnCmd As String = "rs232command4"
Dim RadiobtnCmd As String = "rs232command5"
Dim MusicbtnCmd As String = "rs232command6"
I then have this private sub. For the sake of this thread, what I would like to do is get the name of the label that was clicked which in the code below is already done, convert it to string (not sure if this needs to be done), this is also done in the code below. Next I want to compare the labelnamestring to all the variables in the public class to find out which one it is equal to and then disply that variable which should be my rs232 string in the message box. I have also added "Cmd" to the variable names above so I also need to work out how to add the text "Cmd" to the string to properly compare.
Private Sub Musicbtn_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WatchTvbtn.Click, VolUpbtn.Click, VolDownbtn.Click, SystemOffbtn.Click, Radiobtn.Click, Musicbtn.Click, GardenVolUpbtn.Click, GardenVolDownbtn.Click, GardenRadiobtn.Click, GardenOffbtn.Click, GardenMusicbtn.Click, GardenMediaCenterbtn.Click
Dim labelname As Label = DirectCast(sender, Label)
[Code] .....