还是以你前面的贴子为例: dim r as integer, c as integer dim cellStr(3,3) as string dim r0 as integer,c0 as integer Dim Xl As Object Dim K As New Excel.Application Set Xl = K.Workbooks.Open("C:\123.XLS") r0=5 '起始行,自行设定 c0=5 '起始列,自行设定 for r=0 to 3 for c=0 to 3 cellstr(r,c) = Xl.Worksheets(1).Cells(r+r0, c+c0).Value next c next r
帮我看看下面的程序,运行时会出现“实时错误1004,应用程序定义或对象错误” Option Explicit Private Sub Form_load() Text1.Width = 2000 Text1.Height = 300 Text1.BackColor = &HC0FFFF Text1.Appearance = 0 Text1.Visible = False Dim r As Integer, c As Integer Dim cellStr(3, 3) As String Dim r0 As Integer, c0 As Integer Dim Xl As Object Dim K As New Excel.Application Set Xl = K.Workbooks.Open("C:\123.XLS") r0 = 0 '起始行,自行设定 c0 = 0 '起始列,自行设定 For r = 0 To 3 For c = 0 To 3 cellStr(r, c) = Xl.Worksheets(1).Cells(r + r0, c + c0).Value Next c Next r Text1.Text = cellStr(r, c) End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Visible = False
End SubPrivate Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Picture1.PSet (1100, 2100), vbRed Picture1.PSet (600, 1600), vbRed If X > 1000 And X < 1200 And Y > 2000 And Y < 2200 Then Text1.Visible = True ElseIf X > 500 And X < 700 And Y > 1500 And Y < 1700 Then Text1.Visible = True Else Text1.Visible = False End If End Sub 主要有两个问题:1,数组数据传给文本框对吗, 2,ElseIf后面的数据要怎么写,此时我要用Excel表中cell(2,2)这个数据, (第一个If是要用Excel表中Cell(2,1)的数据) 能不能在麻烦你给我看一下,提示我该怎么改,再次感谢!
dim r as integer, c as integer
dim cellStr(3,3) as string
dim r0 as integer,c0 as integer
Dim Xl As Object
Dim K As New Excel.Application
Set Xl = K.Workbooks.Open("C:\123.XLS")
r0=5 '起始行,自行设定
c0=5 '起始列,自行设定
for r=0 to 3
for c=0 to 3
cellstr(r,c) = Xl.Worksheets(1).Cells(r+r0, c+c0).Value
next c
next r
Option Explicit
Private Sub Form_load()
Text1.Width = 2000
Text1.Height = 300
Text1.BackColor = &HC0FFFF
Text1.Appearance = 0
Text1.Visible = False
Dim r As Integer, c As Integer
Dim cellStr(3, 3) As String
Dim r0 As Integer, c0 As Integer
Dim Xl As Object
Dim K As New Excel.Application
Set Xl = K.Workbooks.Open("C:\123.XLS")
r0 = 0 '起始行,自行设定
c0 = 0 '起始列,自行设定
For r = 0 To 3
For c = 0 To 3
cellStr(r, c) = Xl.Worksheets(1).Cells(r + r0, c + c0).Value
Next c
Next r
Text1.Text = cellStr(r, c)
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Visible = False
End SubPrivate Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PSet (1100, 2100), vbRed
Picture1.PSet (600, 1600), vbRed
If X > 1000 And X < 1200 And Y > 2000 And Y < 2200 Then
Text1.Visible = True
ElseIf X > 500 And X < 700 And Y > 1500 And Y < 1700 Then
Text1.Visible = True
Else
Text1.Visible = False
End If
End Sub
主要有两个问题:1,数组数据传给文本框对吗,
2,ElseIf后面的数据要怎么写,此时我要用Excel表中cell(2,2)这个数据,
(第一个If是要用Excel表中Cell(2,1)的数据)
能不能在麻烦你给我看一下,提示我该怎么改,再次感谢!