繁体   English   中英

我正在VBA Excel中编写编码器。 我不断收到运行时错误13。它说不匹配

[英]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

这会将单词一分为三,直到单词结尾

 T_len = i

拼写每个单词部分的字符

 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

这会将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

这将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

这是将一个元音的单词部分加1

这是发生不匹配的情况

 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

计算机应转换为mci1tpe1ur1

这不是合乎逻辑的声明

If d And x And y = "a" And "i" And "o" And "u" And "e" Then 

这是您要评估的表达式

d
x
y= "a"
"i"
"o"
"u"
"e"

y="a"是一个逻辑表达式。 变量dx也许可以是布尔值,但字符串是绝对不会。 您需要考虑您要在这里说的话。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM