Help with structures!

Jay1b

Contributor
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
Hi

I am trying to put some data into fieldname, fieldstartpos and fieldendpos, from a form, by:

Form Code
FieldName = txtFieldName.Text

This is in a module.
Public Structure FieldRecord ' Create user-defined type.
Public FieldName As String
Public FieldStartPos As Integer
Public FieldEndPos As Integer
End Structure

Public Field_List() As FieldRecord

But the problem i am facing is that is wont recognise fieldname - Could someone please tell me why?

Thanks.
 
What do mean it wont recoginze it? There is an error or what? What you have works for me after I initialized the array to a number.
 
I get the blue line underneath the FieldName in the form code, when its typed in.

I have enclosed the code in a zip below. The error is half way down the 'Private Sub listFields_SelectedIndexChanged' in the frmOptions form.

Thanks.
 

Attachments

I can't open up the zip here, cos I'm at work, but try changing the name fieldname to something else, its probably just a reserved word.
 
Looking at the code the problem seems to be that you haven't declared a variable FieldName anywhere in the form, you will need to reference the structure containing the FieldName member. Something like

Visual Basic:
Dim f As FieldRecord
 f.FieldName = txtFieldName.Text
 
Back
Top