VS 2005 Variable / Constant Name Held In String

Oct 13, 2011

suppose I have variables named A1, A2, A3 ... B1, B2, B3 ... Z97, Z98, Z99. I have a certain operation I want to do using each one in turn. I CAN write a line of code for every single variable, but this will get pretty tedious. I'd prefer it if I can make a function that takes the letter and the number as arguments. So, if it gets the arguments "E" and "10" it will perform the operation on variable E10. What is the syntax for this? say a simple operation such as: result = E10 * 3 Is the syntax any different if I use constants instead of variables?

View 3 Replies


ADVERTISEMENT

TCP - Send A String Held In A Var To An IP Address And Port Number Both Also Held In Vars

Dec 9, 2011

I wish to send a string held in a var to an IP address and Port number both also held in vars. I also wish to listen to a signals coming in on a particular port number so when particular strings are received I can trigger other transmissions.

View 2 Replies

String Must Be Literal. Not A Constant Or A Variable?

Jun 12, 2011

Public Class Form1
Private

[code].....

View 2 Replies

DLL Declaration Won't Accept Constant String Variable?

Apr 26, 2010

I'm making a call to my DLL file (prototyping 30+ functions), and want to be able to switch between different versions of the DLL quickly while in development. Thus, i want to replace the literal string constant that follows the "Lib" key word, with a variable string constant. In case there's any confusion in my use of the jargon. I am currently able to do this:

[Code]...

View 1 Replies

Forms :: Convert A String Variable To Constant

Feb 6, 2010

I am developing an application which initially allows the user to browse and select a save location. The selected path is assigned to a public variable which is used with concatenation to crate folder for saving user input data. How can I change the path string to a constant so the user can run the program again without having to run setup routine unless they want to change the save location?

View 1 Replies

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

Navigate To URL That Is Held As A String In An Array

Jun 24, 2011

I have aproblem with WebBrowser Naviagtion.I would like to navigate to URL that is held as a String in an Array...IF RadioButton.Checked Then WebBrowser. Navigate (Array(0, 0))

View 7 Replies

Parse An XML Dataset Held As A String?

Jan 24, 2010

I am writing a VB.NET application which needs to extract data from an XML document. The Dataset.ReadXML function would be suitable, if the XML document was held in a disk file. However I would prefer the XML document to be passed via a string property of my class object, not as a disk file.

Is there a way to make the ReadXML function take its input from a string instead of a file ? If not, are there other functions which can be made to parse XML which is held as a string.?

View 5 Replies

Assigning Binary Constant To Variable?

Mar 18, 2009

Any way to assign a binary value to a vb variable? All of the obvious choices don't work. I've tried prefixing with &B, appending with b but nothing seems to work.For clarification, what I was looking for (which does not appear to be possible) was how to assign a literal binary number to a variable, in a similar manner in which you can assign a hex or octal number. I was just looking for a more visually engaging way to assign values to a flag enum.

Dim num as Integer = &H100ABC 'Hex'
Dim num2 as Integer = &O123765 'Octal'
Dim myFantasy as Integer = &B1000 'What I would like to be able to do'
Dim myReality as Integer = 2 ^ 3 'What I ended up doing'

View 5 Replies

.net - Constant Values Required In Variable Declartion?

Jun 27, 2012

We are using a custom API in our project which provide an attribute for class fields/members which lets the interface to present a popup of some range values like "On/OFF" and pass the corresponding values of the choice to our code. The attribute requires a string array to know that values.We have many enumerations defined for these ranges,We are thinking to use Enum.GetValues() kind method to get a string array for this method.However, As we know the field declaration do not allow dynamic values in the declaration? so is there any other of doing same thing in efficient way.To clerify the problem i will write the examples below;

Current Working
<RangeLookUp("On:1","Off:2")> Public ASimpleRangeVariable As Integer

While I wanted to do like this or kind of

<RangeLookUp(SomeMethod())> Public ASimpleRangeVariable As Integer
Public Shared Function SomeMethod() as String()
'use Enum to get all the items as string values forexample Enum.GetValues & enu,.GetValues [code]....

Where SomeMethod suppose to return string array to be passed in the RangeLookup constructor.Which means if we change enumeration then we don't have to update the declaration.i know there are better ways to do it but due to some custom API, the ground is limited.

View 1 Replies

Import Xlsx File Into Using TransferSpreadsheet When Path Is Constant But Filename Is Variable

Oct 1, 2009

I use the followoing code to import an xlsx file into an Access 2007 table. It works fine when I enter the exact file name.However, part of the file name is a date which will change every week.The file location does not change,just the date in the file name.[code]I've tried using a wildcard but I get a Run-time error 3011.Db engine could not find the object. Make sure the object exists.

View 1 Replies

VS 2005 Reference A Member Of A Structure By Using A String Variable

Mar 20, 2009

, I was wondering if it was possible to reference a member of a structure by using a string variable. Here's an example of what i'm talking about:

[Code]....

Now, I know that you would usually reference the value in any of the members by using the following (String1 in this case)

[Code]....

View 4 Replies

VS 2005 Copy Each String Element Into The Integer Variable On Each Iteration?

May 19, 2009

Ive got a few strings stored inside a string array, and i need to copy each string element into the integer variable on each iteration.how i would convert it? tried

CInt(stringArr(lc))

but got errors?

View 6 Replies

Use String As A VB Constant?

May 17, 2012

I have strMyColor = "Red".I would like to make lblMyLabel.BackColor to be red.Without using a variable the code would be this:

lblMyLabel.BackColor=Color.Red

I tried using the variable like this: lblMyLabel.backcolor="Color." & strMyColor

But the error is that a string can't be converted to System.Draw.Color. I understand that, as the string "Color.Red" is not the same as the VB constant Color.Red.Is there a way I can construct a valid vbConstant from a string?

View 10 Replies

Search A String Variable And Place The Match Into Another String Variable In Visual Basic?

Nov 18, 2009

I'm looking for a way to search a string variable for two words and copy the text in between them into another variable. This needs to be done as many times as the match occurs.

View 3 Replies

Convert A String To A Constant String?

Jun 9, 2009

I have the following code...

Const ToAddress As String = username.Text & "url..."

which sets to ToAddress to be used in on my Net.Mail.MailMessage that is to be created with the following constructor

Dim mm As New Net.Mail.MailMessage(username.Text, ToAddress)

which takes in a string and a constant string. But I get an error here[url]...

View 6 Replies

Public Constant Versus Private Constant?

Aug 13, 2011

When building a class library which contains many classes, all classes uses a lot of common constants and functions, what is the best to do:

1- Declare these constants and functions as public in a module.

2- In each class declare constants and functions used by individual class as private.

The first choice is good for easy and fast implementation, but re-using a class in a different project will require importing the module to the other project.The second choice require a lot of copy/paste for code snippet but a class can be re-used in different project easily.

View 3 Replies

Can't Convert Integer To String In Constant Expression

Mar 26, 2010

I'd like to understand why one type can't be converted to another type inside a constant expression.

View 13 Replies

Convert A String To Declared Public Constant

Jan 2, 2012

I have declared some constants as double in a Class

[Code]....

I'm tryingto figure out how I can get the text box to display the value of the constant with the same name? i.e 1.54186 in the example given

View 11 Replies

Refactor - Replace With Constant String.Empty

Oct 17, 2011

I have the following line of code
Dim a As String = ""
And the Refactor suggests replacing the "" with String.Empty
It is a kind of Refactoring but why? Since I am a newbie in the future declarations of mine should I better use the String.Empty ?

View 5 Replies

.net - Show Constant String For The Color In Form Designer

Dec 16, 2010

I am working in .Net 2010 framework 2.0 I want to place the constant string for a color property in form designer like GradientBeginColor = MyColor in form designer.

View 1 Replies

Achieve CSS With Constant Values , Arithmetic And String Manipulation?

Mar 30, 2012

When developing ASP.NET websites (using VB.NET web forms) - a lot of my time is spend writing CSS files and they always seem to get messy (code duplication) and very long.

All I want to achieve is to be able to manipulate the CSS using VB.NET code in the following ways:

Use an integer variable to store my "golden" number 7 and use that for width, padding, margin etc where needed
Use string variables to store my "golden" hex color codes e.g. "#44C5F2" and use them for color, background-color, border-color etc. where needed Use an integer variable to set the height of an element and have four child elements each with height: mynum / 4

I just want to use basic VB.net number and string manipulation in order to create a CSS file on the fly.

I understand that the end product - the CSS file shouldn't change much - it should at most change on a daily basis otherwise caching couldn't be used.[code]...

View 3 Replies

Visual Studio Does Not Flag Unterminated String Constant?

May 25, 2010

I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e.

Dim foo as String = "hi

However, the continuous integration tool we are using flags an error:

error BC30648: String constants must end with a double quote.

Is there some language rule in VB.Net that makes a terminating double quote optional "sometimes"? Is there some setting in Visual Studio that will make it flag this as an error, so I can avoid "breaking the build" in this way?

View 3 Replies

Localizing Multi-lined String As One Constant In Resource File

Jan 4, 2010

I have a multi-lined string message that needs to be added to the Resources.resx file of the project. Currently I'm achieving this some thing like this MessageBox(My.Resources.MyMsg1 & vbNewLine & My.Resources.MyMsg2 ). This works.However I'd like to have the entire message in one resource string rather than adding two resources strings to the Resources.resx file.I've tried using' but no luck..message displays as "My message.Rest of the message".I've also tried manually adding a new line in the Resources.resx file. ( by doing "My message.<Shift+Enter>Rest of the message" But message is adding an additional space before the message in the second line.

View 8 Replies

VS 2005 'Variable 'cnn' Hides A Variable In An Enclosing Block

Jul 9, 2009

I have the following code but I get blue squiggly line in cnn and when i point my mouse pointer on it i see this message "Variable 'cnn' hides a variable in an enclosing block".[code]

View 2 Replies

VS 2010 Merging An Integer Variable With A String Variable?

Jun 2, 2011

Say I have something like this

Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")

[code].....

View 7 Replies

Overcome "Conversion From 'Byte' To 'String' Cannot Occur In A Constant Expression." In VB?

Apr 27, 2012

I have this code:

Public Class Beryllium
Public Const AtomicNumber As Byte = 4
Public Const Symbol As String = "Be"

[Code]....

I want to make a list out of all the constants (AtomicNumber, Symbol, Name and AtomicMass). I want to make the list also a constant. When I run the code above, I get an error highlighting AtomicNumber (on line on which I commented on "This line"). I tried .ToString() and CStr() but I get errors on both. Maybe there is a different way to make these constants one string or list (must be public and have new lines)?

View 2 Replies

Combining A String And String Variable Into One Variable

Apr 4, 2009

I am trying to insert a string variable inside of two strings, and make a combined string. Public Sub Page_Load() Dim Id As String Id = Trim (Request.QueryString("Id")) End Sub Dim mp3text as string url... & Id & ".mp3" My goal is to make the mp3text variable have a string that is: url...(If Id is 7) It is for some reason not connecting up correctly. I checked what string it is outputting and this is what it is giving: url...It is missing the Id content.

View 12 Replies

Simulate Key Being Held Down?

Sep 5, 2011

Well i've been trying to make something run with a lot less code(and faster) but it seems with SendKeys some things are getting lost(or discarded) by the program, its only the arrow keys as I try & make it complete a pre-defined maze to see how fast it can be completed.

If I use SendKeys("RIGHT 8") for example the maze usually only moves a few times, sometimes maybe only 1.

Also I looked up how to hold a key down/simulate it but it's not working for the arrow keys(untested on other keys).

The only way i've made it work is delays, decently delayed like 200ms & it's a huge maze but if i hold a key manually I can go much faster yet sendkeys method can't go that fast using individual presses this is why I want to simulate a holding down action.

---it must be working xample code I can make it work for my purpose if it works like on button click, etc....but I tried copying full (supposedly working) codes before & they never worked for me/my key, xample cause i've looked & tried hard(with only failing results).

MORE INFO:Also I tried SendKeys.SendWait() which is meant to wait for keystrokes to be processed & that didn't help either so my best guess is the keystrokes are processed but discarded(like a movement delay code that doesn't queue movements but rather ignores extra movements)

View 12 Replies

VS 2005 Access Of Shared Member, Constant Member, Enum Member?

Apr 28, 2011

Cannot appear to be able to get this function to not have the above error.Private Function GetIncidentActions(ByVal FromAgentID As Integer, ByVal ToAgentID As Integer, ByVal incidentAction As Integer, ByVal ActionDate As Date) As String

[Code]...

View 10 Replies







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