文本框怎样补空格
我有个文本框是4位的,因为名字有长有短,怎样才能在不足4个字符的情况下用空格补足剩余的位置?
你判断字符的长度,如果不到4位的话就把字符串加上空格
dim strname as string =txt_name.Text
if txt_name.Text.Length = 4
strname=txt_name.Text
else if txt_name.Text.Length=3
strname+=" "
else if txt_name.Text.Length=2
strname+=" "
esle
MsgBox("你输入的名字不准确.")
End if
看看这样能不能达到你要的效果的呢.