Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > Concentation
 

Concentation

Hey Guys and Gals,

Is there any way to deconcentate a numeric variable and a string literal.

This is what I'm Trying to do:

I'm taking the value of a textbox, turning it into a numeric variable and then displaying it in a label andconcentating a string literal via code

yearsOldInteger = Integer.Parse(yearsOldTextBox.Text)

yearsOldLabel.Text = yearsOldInteger & " Years Old "

Now this works fine but I need to use the numeric value (before I added the string literal)of the yearsOldLabel.text

in another arithmetic function in the very next statement but I turned it into

a monster. Is there any way to (de)concentate the string from the

numeric value so I can use it in the next statement or would it just

be easier to use labels on the form to identify the output instead of

concentating the variable and the string literal.

Hope This Makes Sense!!!

Thanks.......Eric

Ribeye  Tuesday, March 14, 2006 7:26 AM
Ribeye wrote:

I'm pretty sure I can't use the yearsOldInterger value

because I changed the value by adding the string & "Years Old"

That doesn't change the value of yearsOldInteger, it creates a new string object with the result. You can still use yearsOldInteger in additional calculations.

Mattias Sjögren  Wednesday, March 15, 2006 9:27 AM

If "the next statement" is in the same method, can't you just keep using the yearsOldInteger variable?

Mattias Sjögren  Tuesday, March 14, 2006 7:33 AM

I'm pretty sure I can't use the yearsOldInterger value

because I changed the value by adding the string & "Years Old"

I know I have the string literals commented out in this code

but that is so it will run. If I add one of the strings to the value of the

label text then I get a runtime error.

Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click

yearsOldInteger = Integer.Parse(yearsOldTextBox.Text)

yearsOldLabel.Text = yearsOldInteger '& " Years Old "

monthsOldLabel.Text = (yearsOldInteger * 12).ToString("N0") '& " Months Old "

daysOldLabel.Text = (monthsOldLabel.Text * 31 - 7).ToString("N0") '& " Days Old "

minutesOldLabel.Text = (daysOldLabel.Text * 60).ToString("N0") '& " Minutes Old "

secondsOldLabel.Text = (minutesOldLabel.Text * 60).ToString("N0") '& " Seconds Old"

End Sub

Ribeye  Tuesday, March 14, 2006 7:16 PM
Ribeye wrote:

I'm pretty sure I can't use the yearsOldInterger value

because I changed the value by adding the string & "Years Old"

That doesn't change the value of yearsOldInteger, it creates a new string object with the result. You can still use yearsOldInteger in additional calculations.

Mattias Sjögren  Wednesday, March 15, 2006 9:27 AM

You can use google to search for other answers

Custom Search

More Threads

• Adding list items from delimited text file
• Deleting an object in a list with "For each"
• outsite files
• Get local Ip Details with VB 2008/2005?
• Comparing 2 strings at character level
• Restarting Windows
• Dealing with hex & decimal values & strings in a VB.NET application
• How can I let a user select the location of a database?
• multiline textbox (Better Explained Problem)
• THE DARK AGES OF COMPUTING PART 4 THE BOSSES