0 Replies - 8025 Views - Last Post: 25 May 2007 - 06:22 PM Rate Topic: -----

#1 dsgf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-May 07

load .csv from Resource File and load into 2d array

Posted 25 May 2007 - 06:22 PM

In the following code (see "working code") I open a .csv file from my C: drive and load it's data into a 2d array. It works perfectly,
however I would rather load the .csv data from the Resource File.
I have already created the .res and loaded the .csv as resource 101.
I believe the code should look something like this...

Dim datafile As Long
datafile = LoadResData(101, 10) ' data type is Custom.  10 is defined as [i]user defined[/i]
Open datafile For Input As #1



...however I continue to get runtime error #326 Resource with identifier '101' not found. and my datafile value is 0.
I am a beginner, can you offer any help on what I'm missing?
Thanks in advance!
DSGF


'working code

Private Sub Form_Load()
Dim n As Integer


' add total number of problems - this lis to load my combo dropdown
For n = 6 To 95 Step 1	' Set up 95 repetitions.
	  cmboNumOfProb.AddItem n
Next n

'___________________________________________________________________________________
'The following code opens the Grader.csv file and loads a 2d Array.

Dim a As String, ColumnNames() As String, arrayOfItemsForSingleRow() As String, columnNumber As Integer
  

Open "C:\Personal\Software Solutions\vb\Grader.csv" For Input As #1

  Line Input #1, a$ 'read the column names (first line in file)
  ColumnNames = Split(a$, ",") 'ubound(ColumnNames)+1 is now number of data fields per line
	
  Dim rowNumber As Integer
  
  rowNumber = 0
  
  Form1.MousePointer = 11
  While Not EOF(1)
	
	Line Input #1, a$
	rowNumber = rowNumber + 1
	
	arrayOfItemsForSingleRow = Split(a$, ",")

	'Print eachItem(num)
	
	Debug.Print "Here is the row data..."
	
	'the purpose of the following for-loop is to go through all the columns in this row
	'and populate my 2-D array
	For columnNumber = 1 To UBound(arrayOfItemsForSingleRow)
			
		Debug.Print arrayOfItemsForSingleRow(columnNumber)
		
		Grader(rowNumber, columnNumber) = arrayOfItemsForSingleRow(columnNumber)
   
	Next
	
	'once we're here, all the values have been assigned for THIS row. so, let's go to the next row.....
	'Debug.Print a$
	'Print ColumnNames(1)

  Wend

Form1.MousePointer = 0
  Close #1
	
  frmWelcome.Show
  frmWelcome.SetFocus

  'This is the end of the Array loading code.
  '_____________________________________________________________________________________________
	
  
End Sub


This post has been edited by dsgf: 25 May 2007 - 06:35 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1