And yet another VB6 to VB2005 problem. All helpful suggestions appreciated.
As you can see in the code below, my structures use fixed length strings and
known array sizes. Consequently I can save to files as a large byte array.
This is a series of Lectures where there is a capacity for 8 instructors
with up to 8 lectures each. So a parameters file made from glctInstTable is
2,232 bytes.
The 64 lectures, for the above, each consist of 100 lecture steps each. This
creates a 211,200 byte lecture file.
At the start of the program all parameters are read in. Only a specific
lecture is read in when required, as shown in last item below.
During a program run, if changes are made, they can be written back to the
files on the fly.
Now the problem. I can initialize the array sizes when the program first
calls for reading in the lectures etc. But I do not want to initialize as
fixed length strings. But with variable length strings I can't write a
simple byte array to a file.
There would be no way to use simple math to find a lecture position in such
a file. I would like to avoid using a database approach.
I could pad all strings to a fixed size when writing the file and then trim
(unpad) when reading in the file. This would, of course, be a pain in the
neck.
HELP !!!
GalenS
TYPE DECLARATIONS
' Lecture structures
Private Type ulctLectStruc
FilNam As String * 25
BPMRate As Integer
PgmTyp As Byte
VolLvl(4) As Byte
End Type
Public glctLecture(99) As ulctLectStruc
Private Type ulctInstrStruc
InstName As String * 15
Password As String * 8
LectName(7) As String * 30
Quiz(7) As Integer
End Type
Public glctInstTable(7) As ulctInstrStruc
Public Type stcLectures
InstSelect As Boolean 'Instructor selected
LectSelect As Boolean 'Lecture selected
InstNum As Integer 'Current instructor #
LectNum As Integer 'Current lecture #
QuizNum As Integer 'Current quiz #
LectEdit As Boolean 'force edit
Passwd As Boolean 'password received
Step As Integer 'Current active step
BPM As Integer 'current lect step BPM
Active As Boolean 'Lecture is in use
Advance As Boolean 'Advance or backup direction
PgmType As Byte '0=Film 6=Resp 11=Vet
End Type
Public gLect As stcLectures
OPENING THE LECTURE AND PARAMETER FILES
Temp1 = Len(glctLecture(0)) * 100
Temp2 = Len(glctInstTable(0))
sFile = clsRes.LoadResStgA(401) 'lct file
strCurrFile = gstrPgmPath & sFile
On Error GoTo ErrorHandler ' Enable error-handling routine.
lctFile = FreeFile
Open strCurrFile For Random Access Read Write As #lctFile Len = Temp1 '
Open file for input.
sFile = clsRes.LoadResStgA(400) 'par file
strCurrFile = gstrPgmPath & sFile
parFile = FreeFile
Open strCurrFile For Random Access Read Write As #parFile Len = Temp2 '
Open file for input.
READING THE PASSWORD PROTECTED PARAMETERS FILE INTO STRUCTURES
On Error GoTo ErrorHandler ' Enable error-handling routine.
For Index = 0 To 7 Step 1
Get #parFile, Index + 1, glctInstTable(Index)
strTemp = glctInstTable(Index).Password
For Inner = 1 To 8 Step 1
intTemp = Asc(Mid$(strTemp, Inner, 1)) Xor bytCode(Inner - 1)
Mid$(strTemp, Inner, 1) = Chr$(intTemp)
Next Inner
glctInstTable(Index).Password = strTemp
Next Index
READING IN THE DESIRED LECTURE (OUT OF 64) TO LECTURE STRUCTURE OF 100 STEPS
On Error GoTo ErrorHandler ' Enable error-handling routine.
LectFilePosition = (gLect.InstNum * 8) + gLect.LectNum + 1
Get #lctFile, LectFilePosition, glctLecture 1 1752
"Galen Somerville" <ga***@community.nospam> wrote in message
news:e1*************@TK2MSFTNGP02.phx.gbl... And yet another VB6 to VB2005 problem. All helpful suggestions appreciated.
As you can see in the code below, my structures use fixed length strings and known array sizes. Consequently I can save to files as a large byte array.
This is a series of Lectures where there is a capacity for 8 instructors with up to 8 lectures each. So a parameters file made from glctInstTable is 2,232 bytes.
The 64 lectures, for the above, each consist of 100 lecture steps each. This creates a 211,200 byte lecture file.
At the start of the program all parameters are read in. Only a specific lecture is read in when required, as shown in last item below.
During a program run, if changes are made, they can be written back to the files on the fly.
Now the problem. I can initialize the array sizes when the program first calls for reading in the lectures etc. But I do not want to initialize as fixed length strings. But with variable length strings I can't write a simple byte array to a file.
There would be no way to use simple math to find a lecture position in such a file. I would like to avoid using a database approach.
I could pad all strings to a fixed size when writing the file and then trim (unpad) when reading in the file. This would, of course, be a pain in the neck.
HELP !!!
GalenS
TYPE DECLARATIONS ' Lecture structures Private Type ulctLectStruc FilNam As String * 25 BPMRate As Integer PgmTyp As Byte VolLvl(4) As Byte End Type Public glctLecture(99) As ulctLectStruc
Private Type ulctInstrStruc InstName As String * 15 Password As String * 8 LectName(7) As String * 30 Quiz(7) As Integer End Type Public glctInstTable(7) As ulctInstrStruc
Public Type stcLectures InstSelect As Boolean 'Instructor selected LectSelect As Boolean 'Lecture selected InstNum As Integer 'Current instructor # LectNum As Integer 'Current lecture # QuizNum As Integer 'Current quiz # LectEdit As Boolean 'force edit Passwd As Boolean 'password received Step As Integer 'Current active step BPM As Integer 'current lect step BPM Active As Boolean 'Lecture is in use Advance As Boolean 'Advance or backup direction PgmType As Byte '0=Film 6=Resp 11=Vet End Type Public gLect As stcLectures
OPENING THE LECTURE AND PARAMETER FILES Temp1 = Len(glctLecture(0)) * 100 Temp2 = Len(glctInstTable(0)) sFile = clsRes.LoadResStgA(401) 'lct file strCurrFile = gstrPgmPath & sFile On Error GoTo ErrorHandler ' Enable error-handling routine. lctFile = FreeFile Open strCurrFile For Random Access Read Write As #lctFile Len = Temp1 ' Open file for input. sFile = clsRes.LoadResStgA(400) 'par file strCurrFile = gstrPgmPath & sFile parFile = FreeFile Open strCurrFile For Random Access Read Write As #parFile Len = Temp2 ' Open file for input.
READING THE PASSWORD PROTECTED PARAMETERS FILE INTO STRUCTURES On Error GoTo ErrorHandler ' Enable error-handling routine. For Index = 0 To 7 Step 1 Get #parFile, Index + 1, glctInstTable(Index) strTemp = glctInstTable(Index).Password For Inner = 1 To 8 Step 1 intTemp = Asc(Mid$(strTemp, Inner, 1)) Xor bytCode(Inner - 1) Mid$(strTemp, Inner, 1) = Chr$(intTemp) Next Inner glctInstTable(Index).Password = strTemp Next Index
READING IN THE DESIRED LECTURE (OUT OF 64) TO LECTURE STRUCTURE OF 100 STEPS On Error GoTo ErrorHandler ' Enable error-handling routine. LectFilePosition = (gLect.InstNum * 8) + gLect.LectNum + 1 Get #lctFile, LectFilePosition, glctLecture
This reply doesn't help exactly what you are doing, but a suggestion...have
you tried going the route of datasets? I mean, you can do what you are
trying to using a dataset and saving the file(s) as XML. Loading is just as
easy.
HTH,
Mythran This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: guy |
last post by:
Has anyone any experience of the conversion wizard for VB6 to VB2005?
if so how good is it?
also how does it handle database related conversions i.e is ADO converted to
ADO.NET etc.
the project...
|
by: Oenone |
last post by:
In our applications, we use the special value of DateTime.MinValue to
represent "null dates" throughout all our code. We recently ran into an
issue where we wanted an optional date parameter for a...
|
by: Dennis |
last post by:
I am thinking of getting VB2005 to replace my VB2003 but don't like the idea
of having two files for one form (I have enough files on my computer as it
is). Is there any way to have VB2005 act...
|
by: bz |
last post by:
the vb.upgrade group is dead. I think I will post this here instead.
Hi,
I ran the Upgrade Wizard to upgrade my VB6 project to VB2005 Express
Edition.
I got 140 errors and 170 warnings.
...
|
by: MikeCS |
last post by:
Problem:
I wanted to implement what I did in VB6 where I would use a global structure and dimension an array of structures then the program could load data into it at start up. Global routines would...
|
by: MikeCS |
last post by:
Problem:
I wanted to implement what I did in VB6 where I would use a global structure and dimension an array of structures then the program could load data into it at start up. Global routines would...
|
by: erickwan88 |
last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here.
Indeed, I have no idea on how to get the input from my pen driver...
|
by: kirilogan22 |
last post by:
Okay first of the variables that I have: they are all structures
ex. ALL.vehicles.cars has some functions and and variables/arrays
ex. ALL.vehicles.boats is the same structure as .cars
ex....
|
by: Vae07 |
last post by:
Ok so here is a brief summary of my problem. I need a pop up form that submits input text box information to a pocket excel workbook upon a command botton click. Text box inputs are checked for...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |