可以解决vbscript类型不匹配。这不是真正的不匹配

发布于 2025-02-05 04:50:21 字数 1177 浏览 1 评论 0原文

大家好,我在VB脚本中具有最奇怪的类型不匹配。我不知道该怎么办。

我定义了我的全局变量顶部。

序言:

Public intX, intY, firstX,firstY

intX = CInt(InputBox("Set X Coordinate above ONE in Excel to Start pasting"))
intY = CInt(InputBox("Set Y Coordinate above ONE in Excel to Start pasting"))

firstX = intX
firstY = intY
firstY = CInt(firstY)

然后,我在这里运行了一些代码(注意:Firsty和FirstX未经触摸,它们以某种方式将其视为锚点)。然后,我有以下循环,该循环根据现有行的计数(INTY成为循环的定界符)和某些参数添加行。首先存在,以帮助此循环回落到Excel表的起始位置,以便它可以下降。

Dim x, y, adder, i
adder=1
i=0
x=0
y=0
Do While x<intY
    If ws.Cells(firstY, IntX+3)+ws.Cells(firstY,IntX+5)>1 Then
    adder=ws.Cells(firstY, IntX+3)+ws.Cells(firstY,IntX+5)-1
        For i = 1 to adder
            ws.Cells(firstY+1,IntX).EntireRow.Insert
        Next

    End If
    firstY=firstY+adder+1
    adder=0
    x=x+1
Loop

如果WS.cells(firsty,intx+3)+ws.cells,我会在线路上获得错误类型不匹配:'[string:“”]''在线...那么关于

为什么会发生这种情况的任何想法?

当我打印这些类型时,它们实际上看起来还不错(所有int,但最终随着循环的运行,第一迪斯成为双键),

'   MsgBox TypeName(firstY) &" " & TypeName(x) &" " & TypeName(intY)

如果我像编码克雷匹菌素一样脱落,但我真的不知道在这里做什么。

对故障排除的任何帮助都表示感谢。

Hi all I have the strangest type mismatch in my VB Script. I have no idea what to do.

I define my global variables up top.

Preamble:

Public intX, intY, firstX,firstY

intX = CInt(InputBox("Set X Coordinate above ONE in Excel to Start pasting"))
intY = CInt(InputBox("Set Y Coordinate above ONE in Excel to Start pasting"))

firstX = intX
firstY = intY
firstY = CInt(firstY)

I then have some code running here (note:firstY and firstX go untouched, they are treated as anchors, in a way). Then I have the below loop which adds rows based on the count of existing rows (intY becoming the delimiter for the loop) and certain arguments. firstY exists to help this loop retrace to the starting position of the excel sheet so it can work its way down.

Dim x, y, adder, i
adder=1
i=0
x=0
y=0
Do While x<intY
    If ws.Cells(firstY, IntX+3)+ws.Cells(firstY,IntX+5)>1 Then
    adder=ws.Cells(firstY, IntX+3)+ws.Cells(firstY,IntX+5)-1
        For i = 1 to adder
            ws.Cells(firstY+1,IntX).EntireRow.Insert
        Next

    End If
    firstY=firstY+adder+1
    adder=0
    x=x+1
Loop

I get the error Type mismatch: '[string: ""]' on line If ws.Cells(firstY, IntX+3)+ws.Cells... Then

Any ideas as to why this is occuring?

When I print the types they actually look OK (all int, but eventually firstY becomes type double as the loop keeps going)

'   MsgBox TypeName(firstY) &" " & TypeName(x) &" " & TypeName(intY)

I'm sorry if I come off like a coding cretin but I really don't know what to do here.

Any help in troubleshooting is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文