2015-08-28 131 views
0

代碼應該將字母替換爲圖像鏈接,但它有時會代替例如:heyho去聽,那就是問題所在。請幫助我這個傢伙!替換每一個字母

進口System.Text.RegularExpressions

公共類Form1中 昏暗DefURL = 「http://www.roblox.com/---------------------------------------------------------------------------------------------------------------」 暗淡的myString = 「」 私人小組Form1_Load的(發送者爲對象,例如作爲EventArgs的)把手MyBase.Load

End Sub 
Sub Delay(ByVal dblsecs As Double) 
    Const onesec As Double = 1.0#/(1440.0# * 60.0#) 
    Dim dblWaitTil As Date 
    Now.AddSeconds(onesec) 
    dblWaitTil = Now.AddSeconds(onesec).AddSeconds(dblsecs) 
    Do Until Now > dblWaitTil 
     Application.DoEvents() 

    Loop 
End Sub 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles  Button1.Click 
    myString = "" 
    myString = TextBox1.Text.ToLower 
    Dim sb As String 
    For Each ch As Char In TextBox1.Text 
     Dim s As String 
     Console.WriteLine(ch) 
     Select Case ch 
      Case "a"c : s = "http://www.roblox.com/--item?id=2273128" 
      Case "b"c : s = "http://www.roblox.com/--item?id=2273124" 
      Case "c"c : s = "http://www.roblox.com/--item?id=2273121" 
      Case "d"c : s = "http://www.roblox.com/--item?id=2273119" 
      Case "e"c : s = "http://www.roblox.com/--item?id=2273116" 
      Case "f"c : s = "http://www.roblox.com/--item?id=2273114" 
      Case "g"c : s = "http://www.roblox.com/--item?id=2273111" 
      Case "h"c : s = "http://www.roblox.com/--item?id=2273107" 
      Case "i"c : s = "http://www.roblox.com/--item?id=2273105" 
      Case "j"c : s = "http://www.roblox.com/--item?id=2273102" 
      Case "k"c : s = "http://www.roblox.com/--item?id=2273099" 
      Case "l"c : s = "http://www.roblox.com/--item?id=2273095" 
      Case "m"c : s = "http://www.roblox.com/--item?id=2273093" 
      Case "n"c : s = "http://www.roblox.com/--item?id=2273090" 
      Case "o"c : s = "http://www.roblox.com/--item?id=2273088" 
      Case "p"c : s = "http://www.roblox.com/--item?id=2273086" 
      Case "q"c : s = "http://www.roblox.com/--item?id=2273082" 
      Case "r"c : s = "http://www.roblox.com/--item?id=2273078" 
      Case "s"c : s = "http://www.roblox.com/--item?id=195452703" 
      Case "u"c : s = "http://www.roblox.com/--item?id=2273071" 
      Case "v"c : s = "http://www.roblox.com/--item?id=2273067" 
      Case "w"c : s = "http://www.roblox.com/--item?id=2273065" 
      Case "x"c : s = "http://www.roblox.com/--item?id=2273062" 
      Case "y"c : s = "http://www.roblox.com/--item?id=2273060" 
      Case "t"c : s = "http://www.roblox.com/--item?id=2273073" 
      Case "z"c : s = "http://www.roblox.com/--item?id=2273058" 
      Case " "c : s = "http://www.roblox.com/--item?id=269779634" 
     End Select 
     sb = sb & s 
    Next 
    My.Computer.Clipboard.SetText(sb.ToString) 
End Sub 

結束等級

+1

你的問題是? –

+0

使程序不要替換鏈接中的字母。 –

+0

@KennethK。我編輯了這個問題以明確OP的要求。 – Blackwood

回答

1

爲避免替換已插入的字符串中的字符,您可以循環遍歷所有字符e原始字符串並用替換文本構建一個新字符串。

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    Dim sb As New System.Text.StringBuilder 
    For Each ch As Char In TextBox1.Text 
     Dim s As String 
     Select Case ch 
      Case "a"c: s = "http://www.roblox.com/--item?id=2273128 " 
      Case "b"c: s = "http://www.roblox.com/--item?id=2273124 " 
      Case "c"c: s = "http://www.roblox.com/--item?id=2273121 " 
      Case Else: s = ch 
     End Select 
     sb.Append(s) 
    Next 
    My.Computer.Clipboard.SetText(sb.ToString) 
End Sub 
相關問題