将Textbox.text导入My.Settings.variable时出现问题 [英] Problem getting Textbox.text into My.Settings.variable

查看:60
本文介绍了将Textbox.text导入My.Settings.variable时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,我有一个带有数字值的文本框,并且已将其放入my.settings.long变量中以存储它程序运行之间。

I have a problem in that I have a textbox with a number value in it and have been putting that into a my.settings.long variable to store it between program runs.

这在过去几个月里运行良好。但我不确定如何。它现在不起作用。

This has worked fine for the last couple of months. however I am not sure how. it doesnt work now.

如果我这样做:

"my.settings.banlength(long type)= clng(txtbanlength.text)"

If i do:

"my.settings.banlength (long type) = clng(txtbanlength.text)"

我从字符串"""获得无效的强制转换输入长。

I get invalid cast from string "" to type long.

但文本框不是空的!但命令认为是吗?这是为什么?

BUT the textbox is not emtpy! but the command thinks it is? why is this?

如果我这样做:

txtbanlengh.text = 123456
my.settings.banlength(long type)= clng( txtbanlength.text)

txtbanlengh.text = 123456
my.settings.banlength (long type) = clng(txtbanlength.text)

一切都很好而且有效,但是因为我想要用户输入的值,所以它毫无意义。

All is fine and it works, but its pointless as I want the value from what the user entered.

推荐答案

我建议设一个断点(F9)in

I suggest putting a breakpoint (F9) in

 

my.settings.banlength = clng(txtbanlength.text)

 

检查txtbanlength.text是否真的是"""。

to check if txtbanlength.text really is "".

如果是,那么那里你有问题。您可能想要检查"""并且在这种情况下使my.settings.banlength为0。

If it is, then there you have your problem. You might want to check for "" and make my.settings.banlength 0 in that case.

如果不是,也许你将能够更容易地识别问题。或者,如果不这样做,请尝试替换clng(字符串)。有Integer.Parse(txtbanlength.text),但是如果你想取"长"的话。方法,我会尝试使用isNumeric(txtbanlength.text)检查Long.Parse(txtbanlength.text),

If it isn't, maybe you'll be able to identify the problem more easily that way. Or, if you don't, try an alternative to clng(string). There's Integer.Parse(txtbanlength.text), but if you want to take the "long" way, I would try Long.Parse(txtbanlength.text), after checking with isNumeric(txtbanlength.text).


这篇关于将Textbox.text导入My.Settings.variable时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆