[英]I am writting a encoder in VBA excel. I keep getting a runtime error 13. It says there is a mismatch
Sub Encoder()
Dim word As String
Dim en_word As Variant
Dim i As Integer
Dim wordSec As Variant
Dim d As Variant
Dim x As Variant
Dim y As Variant
Dim T_len As Variant
word = InputBox("Please enter a word")
Sheet1.Cells(127, 6) = word
For i = 1 To Len(word) Step 3
This splits the word in threes till the end of the word 这会将单词一分为三,直到单词结尾
T_len = i
This scrabbles the characters of every word section 拼写每个单词部分的字符
Mid(word, 1, T_len) = wordSec
x = Mid(wordSec, 1, 1)
y = Mid(wordSec, 2, 1)
d = Mid(wordSec, 3, 1)
wordSec = d + x + y
This changes e to u and u to e 这会将e更改为u并将u更改为e
If d = "e" Then
d = "u"
ElseIf y = "e" Then
y = "u"
ElseIf x = "e" Then
x = "u"
Else
x = x
y = y
d = d
End If
If d = "u" Then
d = "e"
ElseIf x = "u" Then
x = "e"
ElseIf y = "u" Then
y = "e"
Else
x = x
y = y
d = d
End If
This changes i to o and o to i 这将i更改为o,将o更改为i
If d = "i" Then
d = "o"
ElseIf x = "i" Then
x = "o"
ElseIf y = "i" Then
y = "o"
Else
x = x
y = y
d = d
End If
If d = "o" Then
d = "i"
ElseIf x = "o" Then
x = "i"
ElseIf y = "o" Then
y = "i"
Else
x = x
y = y
d = d
End If
This is adding 1 to a word section that has a vowel 这是将一个元音的单词部分加1
This is were the mismatch happens 这是发生不匹配的情况
If d And x And y = "a" And "i" And "o" And "u" And "e" Then
wordSec = wordSec + 1
Else
wordSec = wordSec
End If
en_word = wordSec + wordSec
Next i
Sheet1.Cells(127, 14).Value = en_word
End Sub
Computer should translate to mci1tpe1ur1 计算机应转换为mci1tpe1ur1
This is not a logical statement 这不是合乎逻辑的声明
If d And x And y = "a" And "i" And "o" And "u" And "e" Then
This are the expressions you are trying to evaluate 这是您要评估的表达式
d
x
y= "a"
"i"
"o"
"u"
"e"
y="a"
is a logical expression. y="a"
是一个逻辑表达式。 Variables d
and x
Could maybe be boolean values but strings are definitely not. 变量d
和x
也许可以是布尔值,但字符串是绝对不会。 You need to think about what you are trying to say here. 您需要考虑您要在这里说的话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.