Visual Basic在Text1.text和Text 2.text中用另一个字母替换一个字母

时间:2013-10-20 15:46:57

标签: vb6

我有text1.texttext2.textCommand1_Click 在第一篇文章中我有:

WUJ QAZ SFX BG3 YBN HM OTDP WL DG5PY AGEW

没有空间,

我想在单击text2.text上用以下代码替换它:

WUJ - 0

QAZ - 1

SFX - 2

BG3 - 6

YBN - 7

HM - 8

OTDP - B

WL - D

DG5PY - E

AGEW - F

单击

结果text2.text: 012678BDEF

请参见VISUAL BASIC 6.0

1 个答案:

答案 0 :(得分:2)

这是一种方式......

Private Sub Command1_Click()
    Dim str As String
    str = Text1.Text
    str = Replace(str, "WUJ", "0")
    str = Replace(str, "QAZ", "1")
    str = Replace(str, "SFX", "2")
    str = Replace(str, "BG3", "6")
    str = Replace(str, "YBN", "7")
    str = Replace(str, "HM", "8")
    str = Replace(str, "OTDP", "B")
    str = Replace(str, "WL", "D")
    str = Replace(str, "DG5PY", "E")
    str = Replace(str, "AGEW", "F")
    Text2.Text = str
End Sub