小编TMi*_*nos的帖子

拆分功能中的VBA类型不匹配

我写了一个代码,需要从这样的字符串中获取数字:“ 3/1”。我需要将这两个数字存储为2个不同变量中的整数。我已经在2个类中编写了此代码:此函数是我在班级(BigOne)中的拆分函数

Public Function SplitValues(pInput As String, pdelim As String) As String()
'Declaration of variables
Dim strSplit() As String
Dim countDelim As Integer

'Initialization of variables

countDelim = countCharacter(pInput, pdelim)
If countDelim > 0 Then
    ReDim strSplit(countDelim)
    strSplit = Split(pInput, pdelim)
    SplitValues = strSplit
End If
End Function
Run Code Online (Sandbox Code Playgroud)

在主类中,我有一个函数调用此函数,该函数将数字拆分以获取所需的值。但是,我收到“类型不匹配错误”,我无法检测到此类型不匹配的原因。

Public Function get_MaxChars(pInput As String) As Integer
'declaration of variables
    Dim gen As cBigOne
    Dim values As String

   'Main code
    pInput = CStr(pInput)
    Debug.Print (pInput)
    values = gen.SplitValues(pInput, "/")
    get_MaxChars = …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba

3
推荐指数
1
解决办法
5518
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1