Hi
im trying to create a VB program that allows storing and reading to a TXT file i keep getting error 424 object required, im not all to good with VB but i have to get this working for an assignment by thursday. i can (without the loop) read and write a single persons information but i have to save many records . -
-
-
Dim Employee As Object
-
Dim EmployeeCollection As New Collection
-
Dim counter As Integer
-
-
-
Private Sub cmdExit_Click(Index As Integer)
-
-
Dim i As Integer
-
Dim counter As Integer
-
-
counter = EmployeeCollection.Count
-
-
Open "c:\temp\Storage.txt" For Output As #1
-
-
For i = 1 To counter
-
-
Write #1, EmployeeCollection.Item(i).Fullname
-
Print #1, EmployeeCollection.Item(i).Area
-
Print #1, EmployeeCollection.Item(i).Postcode
-
Print #1, EmployeeCollection.Item(i).Address
-
Print #1, EmployeeCollection.Item(i).Contactno
-
Print #1, EmployeeCollection.Item(i).Pos
-
Print #1, EmployeeCollection.Item(i).Salary
-
Next
-
-
Close #1
-
-
End
-
-
End Sub
-
-
-
Private Sub cmdNew_Click(Index As Integer)
-
-
Set Employee = New clsEmployee
-
-
Employee.Fullname = txtFullname.Text
-
Employee.Address = txtAddress.Text
-
Employee.Area = txtArea.Text
-
Employee.Postcode = txtPostcode.Text
-
Employee.Contactno = txtContactno.Text
-
Employee.Pos = txtPos.Text
-
Employee.Salary = txtSalary.Text
-
-
-
EmployeeCollection.Add clsEmployee
-
txtEmployeeno.Text = EmployeeCollection.Count
-
Set Employee = Nothing
-
-
txtFullname.Text = " "
-
txtAddress.Text = " "
-
txtArea.Text = " "
-
txtPostcode.Text = " "
-
txtContactno.Text = " "
-
txtPos.Text = " "
-
txtSalary = " "
-
-
End Sub
-
Private Sub Form_Load()
-
-
Dim FileFullname As String
-
Dim FileArea As String
-
Dim FileAddress As String
-
Dim FilePostcode As String
-
Dim FileContactno As String
-
Dim FilePos As String
-
Dim FileSalary As String
-
-
Set EmployeeCollection = New Collection
-
Set Employee = New clsEmployee
-
-
-
Open "c:\temp\Storage.txt" For Input As #1
-
-
While EOF(1) = False
-
-
Input #1, FileFullname
-
Input #1, FileAddress
-
Input #1, FileArea
-
Input #1, FilePostcode
-
Input #1, FileContactno
-
Input #1, FilePos
-
Input #1, FileSalary
-
-
Employee.Fullname = FileFullname
-
Employee.Address = FileAddress
-
Employee.Area = FileArea
-
Employee.Postcode = FilePostcode
-
Employee.Contactno = FileContactno
-
Employee.Pos = FilePos
-
Employee.Salary = FileSalary
-
EmployeeCollection.Add Employee
-
-
Wend
-
Close #1
-
-
txtEmployeeno.Text = EmployeeCollection.Count
-
txtFullname.Text = EmployeeCollection.Item(EmployeeCollection.Count).Fullname
-
txtAddress.Text = EmployeeCollection.Item(EmployeeCollection.Count).Address
-
txtArea.Text = EmployeeCollection.Item(EmployeeCollection.Count).Area
-
txtPostcode.Text = EmployeeCollection.Item(EmployeeCollection.Count).Postcode
-
txtContactno.Text = EmployeeCollection.Item(EmployeeCollection.Count).Contactno
-
txtPos.Text = EmployeeCollection.Item(EmployeeCollection.Count).Pos
-
txtSalary.Text = EmployeeCollection.Item(EmployeeCollection.Count).Salary
-
-
End Sub
-
-
-
-
-
3 1168
First start with narrowing it down. Which line is the Error 424 occuring on? This will help if you can step through the code during run time and try to determine where its happening.
I also notice you are delclaring a class in your code
Set Employee = New clsEmployee
I assume you have a .cls file that declares the Employee properties?
If so you need to make sure that class is referenced in your references of the project. Also make sure if they are seperate that you have compiled them in the right order. That would be my first guess of the problem.
First start with narrowing it down. Which line is the Error 424 occuring on? This will help if you can step through the code during run time and try to determine where its happening.
I also notice you are delclaring a class in your code
Set Employee = New clsEmployee
I assume you have a .cls file that declares the Employee properties?
If so you need to make sure that class is referenced in your references of the project. Also make sure if they are seperate that you have compiled them in the right order. That would be my first guess of the problem.
the problem is
Print #1, EmployeeCollection.Item(i).Fullname
and i got clsEmployee as the main class and
Fullname
Address
Area
Postcode
Contactno
Pos
and Salary as propities
my collection is Employee
Try defining a new object of type clsEmployee (or whatever it was, I forget). Assign each item from the collection to that object, and print from there, instead of from the collection.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Pkpatel |
last post by:
Hi,
I keep getting this error every time I try to load
crystalreportviewer on a webform with a dataset.
Here is the error:
--------------------------------------------------------
Server...
|
by: Nick Zdunic |
last post by:
I have a remotable object running in my host application.
The host starts up and creates the object. Within a method to start the
remote object doing its thing it creates an object.
...
|
by: mcmg |
last post by:
Hi,
I have an asp app that works fine on a windows xp machine but does not work
on a windows 2000 server.
I have the following code in my global.asa:
<OBJECT RUNAT=Server
SCOPE=SESSION...
|
by: Aaron |
last post by:
I have a data sructure setup and I populate it in a loop like so:
y=0
while X:
DS.name = "ASDF"
DS.ID = 1234
list = DS;
y = y + 1
|
by: 6tc1 |
last post by:
Hi all, I have just finished debugging a windows application and have
solved the problem - however, I want to be sure that I understand the
problem before I move on. Before I detail the problem,...
|
by: blash |
last post by:
Can someone help me? I really don't have a clue.
My company staff told me they often got such error: "Object reference
not set to an instance of an object." when they are in search result
page...
|
by: Arapi |
last post by:
I am having a very strange problem with my asp.net application. I am
getting error: 'Object reference not set to an instance of an object' when I
run my app from my hosting company. I have...
|
by: tommaso.gastaldi |
last post by:
Hi,
does anybody know a speedy analog of IsNumeric() to check for
strings/chars. I would like to check if an Object can be treated as a
string before using a Cstr(), clearly avoiding the time...
|
by: Jeroen |
last post by:
Hi all,
I've got a question about writing a library. Let me characterize that
library by the following:
* there is a class A which is available to the user
* there is a class B that is used...
|
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= |
last post by:
I get the above error in some of the ASP.NET web applications on a
server, and I need some help figuring out how to deal with it.
This is a rather long post, and I hope I have enough details that...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |