VBA输入框无法正确显示字符串?

我正在尝试使用VBA InputBox函数显示提示。在InputBox的文本中,包含一个文件名的字符串变量,但是,当我运行代码时,该字符串(称为“ tempkey”)无法正确显示-中间的某些字符串丢失了。

我已经进入调试器,验证了'tempkey'字符串内容,然后才将它们传递到输入框。只是在InputBox中无法正确显示字符串值。

            tempkey = Left(GetFilenameFromPath(files(i)),Len(GetFilenameFromPath(files(i))) - Len("xxxxmap.xlsx"))

            If Not dict.Exists(tempkey) Then
                entry = InputBox("Please enter a short descriptor for: " & vbNewLine & tempkey & vbNewLine & vbNewLine & "i.e. L5P-LM Post Thermal Cycle")
                If entry <> "" Then
                    dict(tempkey) = entry
                Else
                    Exit Sub
                End If
            End If

字符串“ tempkey”的长度约为109个字符,并且不包含空格。

这是InputBox的样子:

VBA输入框无法正确显示字符串?

如您所见,InputBox中省略了'seq'之后和'from'之前的'tempkey'字符串中的所有内容。

这是我的调试器在显示InputBox之前的值为'tempkey'的样子:

VBA输入框无法正确显示字符串?

为什么字符串显示不正确?

azhenzhen 回答:VBA输入框无法正确显示字符串?

InputBox字符串限制为255个字符,因此我想这就是问题所在。

您是否尝试过将tempkey分为两个单独的字符串?

Dim s1 As String
Dim s2 As String
s1 = Left(tempkey,Len(s) / 2)
s2 = Right(tempkey,Len(s) / 2)

entry = InputBox("Please enter a short descriptor for: " & vbNewLine & s1 & s2 & vbNewLine & vbNewLine & "i.e. L5P-LM Post Thermal Cycle")
本文链接:https://www.f2er.com/3164382.html

大家都在问