我希望软件生成用户发送给我的号码,然后我会通过查看号码了解用户的请求。我会在数字之后放一些数字,例如如果用户想要一个芒果味的冰淇淋,那么将给芒果一个数字。 号码将是 mango_digit + 8(冰淇淋)。但我想完全改变数字,以便任何人都无法理解这个数字。
我试过
Dim number As String = TextBox1.Text
Dim Code1 As String = number.Replace("1", "2")
Dim Code2 As String = Code1.Replace("2", "3")
Dim Code3 As String = Code2.Replace("3", "4")
Dim Code4 As String = Code3.Replace("4", "5")
Dim Code5 As String = Code4.Replace("5", "6")
Dim Code6 As String = Code5.Replace("6", "7")
Dim Code7 As String = Code6.Replace("7", "8")
Dim Code8 As String = Code7.Replace("8", "9")
Dim Code9 As String = Code8.Replace("9", "0")
Dim FINAL_CODE As String = Code9.ToLower
MsgBox(FINAL_CODE)
但代码不起作用。
任何想法? 我也想要一个朋友。 谢谢
答案 0 :(得分:1)
您需要替换,反之亦然,首先是9,然后是8,7,6 ...... 1.否则您也会解码以前解码过的数字。例如,如果" 1"转到" 2",它将被进一步解码为" 3"在下一步。
答案 1 :(得分:0)
尝试以下想法。它给出了完全不同的数字
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim number As Integer = CInt(TextBox1.Text)
Dim l As Integer = TextBox1.Text.Length
Dim n1 As Integer = number + NumberStyle(1, l)
Dim n2 As Integer = number + NumberStyle(1, l)
Dim n3 As Integer = number + NumberStyle(1, l)
Dim n4 As Integer = number + NumberStyle(1, l)
Dim n5 As Integer = number + NumberStyle(1, l)
Dim n6 As Integer = number + NumberStyle(1, l)
Dim n7 As Integer = number + NumberStyle(1, l)
Dim n8 As Integer = number + NumberStyle(1, l)
Dim n9 As Integer = number + NumberStyle(1, l)
Dim d As String = CStr(n9)
Dim Code1 As String = d.Replace("9", "2")
Dim Code2 As String = Code1.Replace("8", "3")
Dim Code3 As String = Code2.Replace("7", "4")
Dim Code4 As String = Code3.Replace("6", "5")
Dim Code5 As String = Code4.Replace("5", "6")
Dim Code6 As String = Code5.Replace("4", "7")
Dim Code7 As String = Code6.Replace("3", "8")
Dim Code8 As String = Code7.Replace("2", "9")
Dim Code9 As String = Code8.Replace("1", "0")
Dim FINAL_CODE As String = Code9.ToLower
MsgBox(FINAL_CODE)
End Sub
Function NumberStyle(ByVal ip As Integer, ByVal tot As Integer)
Dim str As String = ""
For i As Integer = 0 To tot - 1
str += String.Concat(ip)
Next
Dim res As Integer = CInt(str)
Return res
End Function