Declaring Variable Dynamically In .net?

Dec 21, 2011

I have started using the builder class to create my connection strings for the sole purpose of making more generic connectivity code. However, I am stumped on this issue. The MS eConnect product apparently expects to receive integrated security=SSPI in its connection string if you want to use integrated security, (vs Integrated Secturity=True). I thought I would just pass "Trusted_Connection"="SSPI" to the builder class.

as it turns out, the item for Integrated Security is boolean and despite what the documentation says, will not give me SSPI in my connection string. Has anybody else found this issue and is there a simple fix for it? as for now, I'll simply strip out the item and replace it in my string.

View 3 Replies


ADVERTISEMENT

VS 2008 Dynamically Declaring A Constant - Public Const Blah As String = Variable & "something"

Aug 5, 2009

How would I go about dynamically declaring a constant? (It's value is dynamic, not the variable name)

View 5 Replies

Declaring Menu Item Text Dynamically?

Feb 1, 2010

I've been trying to assign text to menu items using a for loop and had no success. I thought this might work but it doesn't:

For i = 1 To 10
Me.Controls("menuItemName").Text = "ladeeda"
Next

View 4 Replies

Declaring Each And Every Variable

Apr 26, 2011

Trying to declare some arrays. I haven't worked with them that I remember. I always took the long road, of declaring each and every variable, but would like to learn this method. The problem is I'm having trouble with the methods I'm finding on the net..[code]for some reason there is a squiggly under each MonsterName except in the declaration that says "declaration expected"

View 16 Replies

.net - Declaring A Byte Variable?

May 30, 2012

We can declare a byte variable like this, for hex '88'

Dim bytes = New Byte() { &H88 } My case, 88 is assigned to a variable, hexvalue

How to declare the byte with the variable hex value?

Dim bytes = New Byte() { &H & hexvalue }the above throws syntax error.

View 2 Replies

.net - Declaring A Variable As Byte

Feb 19, 2011

I'm trying out a program which I found on the net. Why is it necessary to put to curly braces at the end of the statement? It gives an error: "Byte has no constructors". Dim data As Byte() = New Byte(1023) {} I can't put the code like this either, it produces the error "byte cannot be a 1-dimensional array".

[Code]...

View 2 Replies

Declaring A String Variable?

Mar 29, 2012

if this silly but I am trying to declare a string variable by the following line

[Code]...

View 2 Replies

Declaring A Variable For Form And Using It?

Feb 8, 2010

I have declared this variable in a module : Public GenericForm As System.Windows.Forms.Form

and then through code I can asign to that variable a specific form .For example GenericForm = Form1. Then I can use that variable to handle that specific form , for example :

GenericForm.Show

My problem begins when I want to handle a control on that form , for example :

GenericForm.TextBox1.Text = "aaa"

This code creates an error reading :TextBox1 is not a member of System.Windows.Forms.Form.I have been using code like this in VB6 and was quite useful ,but now in VB .NET I cannot .You see I have many forms on which there are some text boxes with the same name,so I declare a generic variable as Form and accordingly insert the code the desired text box conform the form I wish each time . Can I do this in VB .NET too ?

View 23 Replies

Declaring A Variable And Setting It Correctly?

Nov 4, 2010

I'm having a problem declaring a variable and setting it correctly.

BEGIN WORKING CODE:

private sub doSomething
Dim tokenHandle As New IntPtr(0)
Dim dupeTokenHandle As New IntPtr(0)

[Code].....

View 1 Replies

Declaring A Variable Length Array?

Apr 26, 2010

I am new to VB.NET but used to write a lot of code in VB 6.

How do i declare a variable length array in VB.NET?

In VB6, i would just put:

Dim sArrayList() As String

But when I do that in VB.NET, it highlights my array name and says "unused local variable". What do I need to do to get it to work without an error?

View 2 Replies

Declaring A Variable TableAdapter On A Form

Aug 15, 2011

I am building a generic search form in my application. This will allow the user to search for various records throughout the application. The one thing I cannot seem to figure out is how to allow the declaration of the TableAdapter to change at run-time. Each part of the app will be passing a variable to the search form to specify which table should be loaded. In the form class I have the following:

FRIEND WITHEVENTS tbaSearchData AS database.databaseTableAdapters.TableOneTableAdapter This is great for TableOne. But, I have about a hundred tables that could be searched through. To load the data I'm using a DataGridView and populating it via a private method.

View 2 Replies

Declaring Class Variable As A Reference?

Apr 5, 2011

I have a class that I would like to link at construction to a given control (say a textbox)

I know I can put a variable into a subroutine referentially but is there a way to store it in the same capacity?

View 1 Replies

VS 2008 - XML Xdocument - Declaring The Variable

Apr 18, 2010

I've got

Option strict ON
Option explicit ON

How should I declare the variable:-

Dim bounds as? = (From item In xml...<bounds>

[Code]

View 7 Replies

.net - Getting An Advantage To USING Versus Declaring A Context Variable?

Nov 5, 2009

These two snippets do the same thing - is there one that's better than the other, or is it just a matter of preference?

Using context As MyDatabaseDataContext = New MyDatabaseDataContext()
Dim test = context.Employees.Count
End Using

vs.

Dim context As MyDatabaseDataContext = New MyDatabaseDataContext()
Dim test = context.Employees.Count

View 6 Replies

Asp.net - Declaring A Global Request.ServerVariable Variable

Jul 7, 2011

After many many years of using Classic ASP, I am attempting to delve into the world of ASP.Net using VB. I have gotten way to use to being able to declare variables on a page, inlclude that file and use it everywhere. I am struggling to declare a global variable. I just need

[Code]...

View 2 Replies

Declaring A Variable Of Type Interface And Object

Oct 19, 2010

what is the difference between declaring a variable in this way

ByVal
List As IEnumerable as
a parametre in a function
Dim

[Code]....

View 1 Replies

Declaring Private Variable - Automate Properties?

Sep 28, 2009

I come from C# (use VS 2005, .NET 2) and I know that when I declare a private variable I can "extract" from it the corresponding "property". In VB.NET I've declared a lot of properties (in the diagram class designer). Now am I forced manually adding the corresponding private fields?

View 4 Replies

Declaring Fixed Length Variable Arrays In Structure?

May 25, 2012

How do I declare a fixed length variable arra

Structure MyInformation
<VBFixedString(4),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst:=4)> Public ReturnStatus As String

[code]....

View 2 Replies

Declaring Object Variable - Inactive During Initialization Of Module?

Feb 16, 2012

Got a question regarding declaring a variable. Basically I have a module that writes to a text file using textwriter which is declared for the whole module to use at the top of the code. But what I want to do is clear the contents of the text file when the program is executed (using file.writealltext). The problem I have is that the file is obviously already in use as a result of the textwriter and the file cannot be modified because of this.

My question is: is there any way of declaring the textWriter object later on (not during the initial initialization of the module) without passing the object between functions? Setting the variable as inactive or something along those lines during initialization would be ideal.

View 1 Replies

Gained By Using The Function Itself To Hold The Return Value Instead Of Declaring A Local Variable?

Oct 28, 2010

What's best practice (in VB.Net):

Function GetSomething() as String
GetSomething = "Here's your string"
End Function
or
Function GetSomething() as String
Dim returnString as String = "Here's your string"
Return returnString
End Function

Obviously, neither of these implementations make any sense, but they're just meant to illustrate my point. Is there anything to be gained by using GetSomething itself to store the return value instead of declaring returnString locally and then returning that (does it avoid having an extra string allocated/instantiated - and if so, are there any performance/memory benefits)?

View 6 Replies

Late Binding - Declaring A String Variable And Assigning The Item Property?

Nov 27, 2011

I have a problem involving late binding, and I absolutely cannot for the life of me figure out how to fix it. I have spent hours researching the problem to no avail, so I am turning to stackoverflow as a last resort.The problem is pretty much this: I am creating a grocery list application. I have a class named Item which stores the name, price, quantity, and description of an item on the grocery list. I have a module named ListCollection which defines a Collection of Item objects. I have created an Edit form which will automatically display the currently selected ListCollection item properties, but whenever I attempt to fill the text boxes, it tells me that Option Strict disallows late binding. I COULD take the easy route and disable Option Strict, but I'd prefer to figure out what the problem is so I know for future reference.I shall paste pertinent code here. (Late binding error is in EditItem.vb)

[code]...

I have tried declaring a String variable and assigning the Item property to that, and I have also tried grabbing the value directly from the List item (not using the Get function), and neither of these made a difference.

View 1 Replies

'dynamically' Refer To A Variable?

Aug 18, 2010

I have a bunch of string variables, string1, string2, string3 etc.At the end of my program I want to write these strings to a file, but I don't want to have to laboriously type out string1, string2, string3 etc.

It would be much easier to use a loop to dynamically refer to (string & loopcounter), ie reference the variable by dynamically concatenating its name from a string and a number. Python can do this with eval(). How does VB do it? I can think of loads of examples where it'd be useful. Otherwise I have to type out all the different conditions and that's not efficient.

View 1 Replies

Declare A Variable Dynamically?

May 9, 2012

I have searched online for a few hours to try to figure out how to do this, but nothing I found really makes sense, so could someone please tell me, in a simple way, how to do this?

Let's say I have a text box that the user fills out, named textbox1. And I have a combo box, named combobox1, which contains the choices A, B, C. And then I have a button named submit_button.

Each time that the user clicks submit_button, I would like to dynamically create a new variable. This variable should be named the same as textbox1.text, and should contain the value of combobox1.

For example, if the user types "blue" into textbox1, and chooses value "C" from combobox1, and then clicks submit_button... then the following variable should be dynamically created, like..Dim blue as String = "C"

And then, after that, if the user types "red" into textbox1, and chooses value "B" from combobox1, and then clicks submit_button... then another variable should be dynamically created, like...

Dim red as String = "B"

And each time the user submits new information into the textbox and combobox, a new variable should be created.Is it possible to have the program automatically create variables like this? If so, how?

My actual project is much more complicated than this, of course, so the above is just an example. But if I could figure out how to solve the problem in this example, I could figure out how to solve the entire project.

View 6 Replies

Dynamically Increment Variable Name In ASP.NET?

Jun 7, 2012

I am using the AJAXToolkit Accordion control and dynamically adding panes to it based on a query of the database. For example:

Jane logs in and pulls up the page with the accordion on it. In the database she has five rows in the todo_list table. So, I need to dynamically generate five panes that contain the info. from the table...but if Joe logs in he may have only three rows, and Josh may have fifteen - so I can never know how many an individual will have beforehand.

So, I need some way to dynamically name the variables (or is there another way to do this). For example, here is some pseudo-code of what I'm trying to accomplish:

Dim i as integer
For each row in todo_list
Dim ap + i as New AccordionPane
Add some info from the row to the pane
Next

View 1 Replies

Dynamically Assign Type Of Variable?

May 15, 2010

Is it possible to declare a variable and to choose it's appropriate type during runtime?

it should be something like this (of course, the last line does not work):

'Determine what type of variable is needed later

Dim myVariableType As System.Type = System.Type.GetType("System.String", True, True)

'Create variable with needed type

Dim myVariable As myVariableType ' Should be a string variable in this case

View 5 Replies

Dynamically Change Variable Types?

May 10, 2010

I'm trying to make an application to do mathematical equations, but I also want to implement error checking. So that if someone doesn't put anything in one of the fields the output textbox will say "Error".

But the problem is that I already declared the variables I used as a numeric value, in my case decimal.

So, when I make an if statement that says if inputbox1="" then outputbox1="Error" it doesn't work.

I think that in order to get this to work I would have to have it setup so that the variable that is exported to the text property of outputbox1 could switch between being declared as a decimal or string value based on what the user put into the textboxes. But I'm not sure how to go about this. Declaring the variables inside the if/elseif statements won't work because the variables need to be declared before they are calculated within my if/elseif statements.

View 1 Replies

How To Declare DataType Of Variable Dynamically

Jul 6, 2010

How can I define the datatype of an variable dynamically. I read out data from a file. In the file it is specified, if the raw-data is interpreted as single, integer or .... So my idea is: To check, what datatype is in use and then declare an array with this datatype to store the data there.

View 2 Replies

Php - Dynamically Choose And Set Class Variable?

Nov 4, 2010

I want to set a variable in a class. But I want to dynamically choose which variable to set.

[Code]...

View 1 Replies

VS 2010 : Dynamically Dimension A Variable?

May 5, 2010

is it possible to dynamically dimension a variable?in my case, i have a chart that has a varying number of series on it depending on the data extracted and in order to use those series, i have to dimension them manually before adding points to them, IE:

Dim series1 as New Series()
Dim series2 as New Series()
etc
etc

my series data is contained in a datatable, so i'll know the count required, but it will change at runtime, so obviously doing something like this won't work, but explains what i'm trying to do:

dim recordcount as integer = datatable.rows.count
for i = 1 to recordcount
dim "series"+recordcount.tostring as new series()
next

View 13 Replies

Dynamically Referencing Class Property With A Variable?

Feb 4, 2009

So Im iterating through the properties of a class. For each property Im iterating through a datatable until I find a column name with the same name as the property.

No worries so far, here's the isse: Once I've found a match I want to set the class's property to the value in the datatable but I'm having difficulty referencing the property as it has to be done through a variable.

Code:
Dim per As New Person
Dim t As Type = per.GetType
For Each p As PropertyInfo In t.GetProperties

[Code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved