Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Aask  
#1 Posted : Wednesday, November 14, 2018 1:15:15 AM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

I have the following code:
Quote:
Private Sub UserForm_Activate()
iGrid1.ColCount = 20
iGrid1.RowCount = 20
Dim b(8, 8) As Variant
For i = 2 To 9
For j = 2 To 9
b(i - 1, j - 1) = ActiveSheet.Cells(i, j).Value
Next
Next
Dim DirArray As Variant
DirArray = Array(Range("a2:h9").Value)
DirArray2 = [a1:a5].Value2
iGrid1.LoadFromArray 1, 1, b, False ' Works
'iGrid1.LoadFromArray 1, 1, DirArray, False ' Fails
'iGrid1.LoadFromArray 1, 1, DirArray, False ' Fails
End Sub
This is from Excel VBA. I'd like to understand why, of the last 3 lines in the subroutine, why the latter two fail and possibly what the resolution is.
Thanks.
Igor/10Tec  
#2 Posted : Thursday, November 15, 2018 3:38:47 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,035

Thanks: 14 times
Was thanked: 133 time(s) in 133 post(s)
Yes, really, there is a problem with the LoadFromArray function when you use it with an array returned by the Range().Value call in Excel VBA. Before doing its main work, LoadFromArray checks whether a correct array with 1 or 2 dimensions is passed to the method. This check is based on low-level API calls and the COM SafeArray type used internally by the VB runtime to work with arrays. It turned out, that this approach does not work in Excel VBA - at least, in the latest versions of Excel.

I implemented another approach to get the number of array dimensions and compiled a new interim build of iGrid with this bug fix. It has been already sent to you in a private email. Test this new build of iGrid and let us know whether it works correctly.

One comment to the following code snippet:

Code:
Dim DirArray As Variant
DirArray = Array(Range("a2:h9").Value)
iGrid1.LoadFromArray 1, 1, DirArray, False


There is no need to wrap the Range().Value call with the Array() function. Doing so you create an array with 1 item, and this item contains a 2-dimensional array returned by Range().Value. It will be an array nested into another array. To make this code work with the LoadFromArray method in iGrid, use the following syntax:

Code:
DirArray = Range("a2:h9").Value
Aask  
#3 Posted : Thursday, November 15, 2018 4:55:29 AM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

Igor,

Thanks for the response.

The code snippet is not exemplary - it is the result of various things I had been trying - but I think it does the job of explaining the issues I was having.

I could not work out whether it was the Variant data type or the By Ref that was the root cause.

Variant data type are a little problematic in the sense that, in the same scope or context, you can create two Variant arrays using alternative pathways and one is 0-based and the other is 1-based.

By Ref usually means that iGrid (the server) can change a variable in my application (the client). That is not the case with the LoadFromArray method.

It turns out that the problem was a flaw in iGrid and it was neither 0-based nor By Ref.

The new version works!

Thank you very much.
Gkir  
#4 Posted : Tuesday, November 20, 2018 7:45:19 AM(UTC)
Gkir

Rank: Newbie

Groups: Registered
Joined: 11/20/2018(UTC)
Posts: 1
Location: Quebec

How do I access the new version? On the download page?
Igor/10Tec  
#5 Posted : Tuesday, November 20, 2018 8:24:48 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,035

Thanks: 14 times
Was thanked: 133 time(s) in 133 post(s)
The fixed version of the method will be available soon in the next public update of the control. If you need it urgently, send us a letter with your registration data to check whether the latest interim build of the control is available for you for free during the paid maintenance period.
Igor/10Tec  
#6 Posted : Monday, November 26, 2018 8:37:02 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,035

Thanks: 14 times
Was thanked: 133 time(s) in 133 post(s)
The fixed version of the LoadFromArray method is available in iGrid ActiveX 7.0 released today.
Troy  
#7 Posted : Saturday, May 4, 2019 2:33:19 PM(UTC)
Troy

Rank: Newbie

Groups: Registered
Joined: 2/20/2017(UTC)
Posts: 5
Location: Maine

I just purchased Version 7.00.0015 of ActiveX iGrid as I was having issues with loadfromarray in 6.X. Seems like there was a known bug in 6.X but was resolved in 7.X. My error wasn't necessarily the Range() issue, it just simply failed.

To test 7.X, I added two new 7.X grids, configured them with identical columns, loaded the first grid the normal way, then ran this code (from the example in the chm document):

Code:

Dim arr(1 To 10, 1 To 5) As Variant
frmMain.iGrid1.LoadIntoArray 1, 1, arr
frmMain.iGrid2.Clear
frmMain.iGrid2.LoadFromArray 1, 1, arr


I can see that iGrid1 loads correctly and all the expected data is loaded.

I thought maybe it was the dimension of the array so I tried several combinations trying to match the exact number of columns and such, but no luck. On the frmMain.iGrid2.LoadFromArray line, I get the Subscript out of range error.

What might I be doing wrong?

Thanks.

Troy
Igor/10Tec  
#8 Posted : Sunday, May 5, 2019 11:44:44 PM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,035

Thanks: 14 times
Was thanked: 133 time(s) in 133 post(s)
Troy, can you publish here or send us a sample demonstrating this issue?
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.