问题描述
我有一个简单的翻译程序我在2010年VB工作。
I have a simple translating program i working on in vb 2010.
我有一个组合框和一个文本框和一个按钮。
I have a combobox and a textbox and a button.
是我迄今为止在您选择的文本框和按钮将出现在组合框的选项。那么当你输入的东西它用一些新的东西,在相同的文本每个字母。
What i have so far is when you select the option in the combobox the textbox and button will appear. then when you type something it replaces each letter with something new, in the same textbox.
我无法弄清楚是如何使它所以在那里,如果我再次点击该按钮将它转换替换字母回到原来的。
what i cant figure out is how to make it so where if i click the button again it translates the replaced letters back to the original ones.
怎么会这样做?
推荐答案
尝试复制你的文本字符串则在更换之前,然后更换与您的字符串的内容文本框中的文本,当你点击你的第二个按钮类似这一点。
Try copying your text to a string before you replace it, then replace the text in the textbox with the contents of your string when you click your 2nd button something like this.
Public Class Form1
Dim backingString As String
Dim bConverted As Boolean
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Not bConverted Then
backingString = TextBox1.Text
bConverted = True
If TextBox1.Text.Contains("A") Then
TextBox1.Text = TextBox1.Text.Replace("A", "/-\")
End If
Else
TextBox1.Text = backingString
backingString = ""
bConverted = False
End If
End Sub
End Class
这篇关于VB怎样才能让按钮刷新回原始文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!