Private Sub Command1_Click() Dim S0 As String Dim i As Integer Dim S As String Dim temp As StringS0 = "ATATATAGCGCGCA"For i = 1 To Len(S0) temp = Mid(S0, i, 1) Select Case temp Case "A" temp = "T" Case "T" temp = "A" Case "G" temp = "C" Case "C" temp = "G" End Select S = S + temp NextPrint S0 Print S End Sub
Option ExplicitPrivate Function trans(ByVal s0 As String) As String Dim i As Integer Dim S As String Dim temp As StringFor i = 1 To Len(s0) temp = Mid(s0, i, 1) Select Case temp Case "A" temp = "T" Case "T" temp = "A" Case "G" temp = "C" Case "C" temp = "G" End Select S = S + temp Next trans = S End FunctionPrivate Sub Command1_Click() Text2.Text = trans(Text1.Text) End Sub
Dim S0 As String
Dim i As Integer
Dim S As String
Dim temp As StringS0 = "ATATATAGCGCGCA"For i = 1 To Len(S0)
temp = Mid(S0, i, 1)
Select Case temp
Case "A"
temp = "T"
Case "T"
temp = "A"
Case "G"
temp = "C"
Case "C"
temp = "G"
End Select
S = S + temp
NextPrint S0
Print S
End Sub
出错一般是变量类型不匹配,
你参考思路做相应的更改.或直接改为Variant变量.
Private Sub Command1_Click()
Dim str1 As Stringstr1 = Replace("ATATATAGCGCGCA", "A", "@")
str1 = Replace(str1, "T", "A"): str1 = Replace(str1, "@", "T")
str1 = Replace(str1, "G", "@"): str1 = Replace(str1, "C", "G")
str1 = Replace(str1, "G", "C")TEXT2.TEXT=STR1
End Sub
s="ATATATAGCGCGCA"
s=replace(s,"T","A")
s=replace(s,"C","*")
s=replace(s,"G","C")
s=replace(s,"*","G")
界面如下
Option ExplicitPrivate Function trans(ByVal s0 As String) As String
Dim i As Integer
Dim S As String
Dim temp As StringFor i = 1 To Len(s0)
temp = Mid(s0, i, 1)
Select Case temp
Case "A"
temp = "T"
Case "T"
temp = "A"
Case "G"
temp = "C"
Case "C"
temp = "G"
End Select
S = S + temp
Next
trans = S
End FunctionPrivate Sub Command1_Click()
Text2.Text = trans(Text1.Text)
End Sub