Hello
For my project, I made a program that computes for FG (Final Grade) of a student, and lists the students who receive awards.
How do I save these data? (the values of the variable FG and the contents of the listboxes) I'm thinking of having a save button, and I really need the code for it, but I can't find a working one anywhere. Also, is it better to save as a text file or as a database? (I'm a moderate beginner, so I don't know what a database is like.)
By the way, I use Visual Basic Express Edition 2008.
If it helps, the listbox names are listVAExcel, listVALead, listCAExcel, and listCALead.
Thank you very much and I hope for your prompt replies! :D
1 1651
This is an example in VB6 how to save data of your 4 lists in the application directory in a file:(demo see attachment) -
Private Sub ComSave_Click()
-
Dim FNumSave As Integer
-
Dim LISTidx As Integer
-
FNumSave = FreeFile()
-
On Error GoTo Error_Saving
-
Open App.Path & "\settings.ini" For Output As #FNumSave
-
Write #FNumSave, "[ listVAExcel ]"
-
With listVAExcel
-
For LISTidx = 0 To .ListCount - 1
-
Write #FNumSave, .List(LISTidx)
-
Next
-
End With
-
Write #FNumSave, "[ listVALead ]"
-
With listVALead
-
For LISTidx = 0 To .ListCount - 1
-
Write #FNumSave, .List(LISTidx)
-
Next
-
End With
-
Write #FNumSave, "[ listCAExcel ]"
-
With listCAExcel
-
For LISTidx = 0 To .ListCount - 1
-
Write #FNumSave, .List(LISTidx)
-
Next
-
End With
-
Write #FNumSave, "[ listCALead ]"
-
With listCALead
-
For LISTidx = 0 To .ListCount - 1
-
Write #FNumSave, .List(LISTidx)
-
Next
-
End With
-
Write #FNumSave, "[ EOF ]"
-
Close #FNumSave
-
Exit Sub
-
Error_Saving:
-
MsgBox "error saving file"
-
Close #FNumSave
-
End Sub
-
___________________________________
-
-
Private Sub ComLoad_Click()
-
Dim FNumLoad As Integer
-
Dim LISTidx As Integer
-
Dim INPUTDATA As String
-
FNumLoad = FreeFile()
-
On Error GoTo Error_Loading
-
Open App.Path & "\settings.ini" For Input As #FNumLoad
-
Input #FNumLoad, INPUTDATA '§ first line
-
Do Until INPUTDATA = "[ EOF ]"
-
Select Case INPUTDATA
-
Case "[ listVAExcel ]"
-
Input #FNumLoad, INPUTDATA '§ first data
-
Do Until Left(INPUTDATA, 2) = "[ " '§ until next header
-
listVAExcel.AddItem INPUTDATA
-
Input #FNumLoad, INPUTDATA
-
Loop
-
Case "[ listVALead ]"
-
Input #FNumLoad, INPUTDATA
-
Do Until Left(INPUTDATA, 2) = "[ "
-
listVALead.AddItem INPUTDATA
-
Input #FNumLoad, INPUTDATA
-
Loop
-
Case "[ listCAExcel ]"
-
Input #FNumLoad, INPUTDATA
-
Do Until Left(INPUTDATA, 2) = "[ "
-
listCAExcel.AddItem INPUTDATA
-
Input #FNumLoad, INPUTDATA
-
Loop
-
Case "[ listCALead ]"
-
Input #FNumLoad, INPUTDATA
-
Do Until Left(INPUTDATA, 2) = "[ "
-
listCALead.AddItem INPUTDATA
-
Input #FNumLoad, INPUTDATA
-
Loop
-
End Select
-
Loop
-
Close #FNumLoad
-
Exit Sub
-
Error_Loading:
-
MsgBox "error loading file"
-
Close #FNumLoad
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: I Decker |
last post by:
Hi all,
Hope this is the right group.
I am writing a program in c# to open create an excel document, enter
some data, save it and then email it as an attachment. I have
successfully created...
|
by: a |
last post by:
Save text file as html kloepper 17:42 23 Jul '04
I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html...
|
by: Mr Gordonz |
last post by:
Hi All,
I want to be able to save a file from the client's PC on the server. The
tricky part is the aspx page is never actually seen by the user. Basically,
I have a VB application running on...
|
by: Patrick |
last post by:
Following on from the excellent example at
http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp
on how to save a data-grid to excel file, how can I extend the example such...
|
by: needin4mation |
last post by:
I have data I am reading from a database.
I want to take that data, parse it, and put it in between html tags.
When I have that row completed in between all the tags, then I want to
save that...
|
by: Matt |
last post by:
Hi,
I would like to save a file locally (on the client computer) in an ASP.net
application.
It is like the server would return some data that the user can save to a
file on his local PC.
The ASP...
|
by: Darius |
last post by:
Hello,
there is an NMEAParserDemo application written in VC++ avaliable for
download from
http://www.visualgps.net/Papers/NMEAParser/NMEAParserDemo%20Project.zip.
Source code in VC++ is...
|
by: phpnoob |
last post by:
I have a php script that processes a form and then posts the user
input to a data file on the server in a comma delimited format. For
simplicity call the file "data.csv." The script is working...
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
I have a question for you.
I have a .csv file which has many lines of data.
Each line has many data fields which are delimited by ",".
Now I need to extract part of data from this...
|
by: dougancil |
last post by:
I have the following code:
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |