gpt4 book ai didi

vba - 使用MsgBox创建和提取名称变量的语法错误

转载 作者:行者123 更新时间:2023-12-03 08:07:57 25 4
gpt4 key购买 nike

我正在尝试执行宏以使用MsgBox创建和提取名称变量。我试图在MsgBox代码中不使用'_'来运行它,但是它没有用。它显示一条消息,说明定义名称等于Steve Jobs的代码中存在语法错误。

Sub test1()
Dim name as string, lname as string, fname as string
name = “Steve Jobs”
lname = right(name, 4)
fname = left(name,5)
Msgbox “First name is” & fname & “” & “ the number of characters are” & len(fname)
Msgbox “Surname is” & fname & “” & “ the number of characters are” _ & len(fname)
End Sub

最佳答案

Sub test1()
Dim name As String, lname As String, fname As String
name = "Steve Jobs"
lname = Right(name, 4)
fname = Left(name, 5)
MsgBox "First name is " & fname & "" & " the number of characters is " & _
Len(fname)
MsgBox "Surname is " & lname & "" & " the number of characters is " & _
Len(lname)
End Sub

您使用的引号看起来很奇怪,这样就可以了

关于vba - 使用MsgBox创建和提取名称变量的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49631584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com