|
-
Feb 5th, 2002, 07:23 PM
#1
Thread Starter
New Member
UDT to flexgrid type mismatch
Hi folks. I don't know quite what is happening and it may not concern the flexgrid directly but have a look at this, please.
The UDT is defined in a standard module. When it runs I get a type mismatch at Storm()*. Can any one see why. I have moved everything everywhere to no avail and put every possible argument in the brackets. The grid is set as 31 rows of 4 cols as the file the UDT writes to is made per month but clearly will not always be full. IE the file/array will mostly be smaller than the grid, will this make a difference ?
Thanks for any help Bungowomble.
Private Sub cmdArray_Click()
weatherdata2.Show
Dim Storm() As Weather
Dim I As Integer
Dim X As Integer
Dim Y As Integer
TotRecs = LOF(FNum) / Len(WRec)
ReDim Storm(TotRecs)
Open "Climate" + txtmonth.Text + ".dat " For Random As FNum Len = 29
For I = 0 To TotRecs
Get FNum, I, WRec
Storm(I) = WRec
Next I
Close FNum
For X = LBound(Storm, 1) To UBound(Storm, 1)
For Y = LBound(Storm, 2) To UBound(Storm, 2)
weatherdata2.flxMonth.TextMatrix(X, Y) = Storm(X, Y)*
Next Y
Next X
End Sub
-
Feb 6th, 2002, 01:44 AM
#2
PowerPoster
Hi
U have dimensioned Storm as a one dimensional array...
ReDim Storm(TotRecs)
and then attempt to read it back as a two dimensional array...
TextMatrix(X, Y) = Storm(X, Y)*
U should set a counter within the X and Y loop that increases by one each time and thereby gets the next item in the Storm array.
PS I have no idea what these lines are supposed to mean
For X = LBound(Storm, 1) To UBound(Storm, 1)
For Y = LBound(Storm, 2) To UBound(Storm, 2)
I think that u have ur whole array structure a bit messed up. Maybe if u give a bit more info I can help u further...
eg Is Storm supposed to be a 2d variable with month and day dimensions?
Regards
Stuart
-
Feb 6th, 2002, 07:30 PM
#3
Thread Starter
New Member
Hi Stuart;
The idea of the procedure is that I have a UDT defined as:
Type As Weather
Temp As Str
Precip As Str
Cloud As Str
Day As Str
End Type.
This is in a standard module. Then in the form General Dec' I dimensioned WRec As Weather. This works ok in the enter and single sequential retrieve functions .
Then I dim'ed Storm() AS Weather to receive the Random Access file contents back so I can display the whole file. This is where the problem starts. The aray is dynamic as the file will vary in size day to day. The idea is to enter one record each day for a month. This is where the type mismatch occurs. The 2 lines you don't understand came from a tutorial I tried to adapt I guess without knowing what I am doing. The flexgrid is totally new to me so I am having difficulty with its structure. It is defined as 31 rows each having 4 fields(cols) thus I treated the statement as if the array has 2 dimensions as it is effectively going to be an X by 4 array, up to 31 by 4.
Regards Bungowomble.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|