不确定我是否做错了,基本上我的代码从“111111111”开始,每次线程能够通过在原始数字上加“1”来计算。我希望方法在序列中跳过0,而不是在“111111119”之后转到“111111120”,我希望它直接转到“111111121”。
Private Sub IncreaseOne()
If count < 999999999 Then
count += 1
Else
done = True
End If
If CStr(count).Contains("0") Then
MsgBox("theres a 0 in that...darn.")
CStr(count).Replace("0", "1")
End If
End Sub
*注意,我的消息框会在显示时显示,但是0不会更改为1s
答案 0 :(得分:7)
Replace返回一个带有Replace的效果的字符串,它不起作用....
(请记住,在.NET中,字符串是不可变对象)
Dim replaced = CStr(count).Replace("0", "1")
但是,您需要将获取的字符串转换为整数并重新分配给count。
count = Convert.ToInt32(replaced)
答案 1 :(得分:0)
Replace是一个返回刺痛的函数。
换句话说,您需要一个变量来保存结果,如下所示:
Dim newValue = CStr(count).Replace("0", "1")