简体   繁体   中英

How do i get value from string textBox in C#

I am newbee here right now, i'm trying to solve my problem code but it's doesn't clear. I want to get value from my string textBox.Text . initial textBox is hmI7Segment1.Text . it's has string Format as Channel1.DV1.DB1.Level1 . i wish to convert double value from this string into textBoxTarget.Text . so, here is code problem:

hmI7Segment1.Text = "Channel1.DV1.DB1.Level1";
TextBox txtBoxTarget = converted.Format [hmI7Segment1.Text] as TextBox; 

if all of you have solution, please help me to solve my case. thanks for all of you are.

Marbun

So if I understand correctly you wish to convert a value of a textbox which is a string, to a double right?

In that case you can do something like this:

Var stringInput = textbox.Text;

If(double.TryParse(stringInput, out var doubleInput))
{
//Do something with the double value
}
Else
{
//Input is not a valid double value, handle it by showing an error or something
}

Also you didn't specify the technology of your UI, is it forms or wpf?

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM