VB6 Help...

Hello, I am new here at these forums but I am simply looking for some VB6 coding help…

I am creating an Hour Logging program in VB6 for my school’s tech staff, and I am wondering If you guys could help me out with this problem I am stuck on. I could do it the hard way, or I could just ask you guys if there is an easier way.

Situation:

I have a ComboMenu with a List of Names. This is for Loggin hours under this specific name.

I have an Hours text box, For logging specific hours under each name.

And I have a Job text box, for logging what type of jobs you did during the time.

Here is a screenshot of the main interface:

As you can see, I have an exit button (self explanitory), a clear button, which clears all fields, and “add” button, that adds the information to a specific log, an Options button, which has a few basic options, and a My Log button, for viewing the stored Logs.

My question is, is there an easy way of coding the “add” button, to;

  1. Add the Information to the log in an Organized fashion

  2. Save the Log for future use

  3. Do the above without going through each string saying “if comboname=”" then Add ect… ect… ect…"

I could do it this way, but the problem I would have is this:
Under the “options” menu, I have the option to create another Staff Member. When clicked on, is there a way to have it create another form/log/identity without me manually changing any of the code? I have an idea in my head, but I’d like to ask someone who knows a bit more before I go off exploring…

EDIT:
I got impatient and went off exploring :confused:

This is what I am thinking, but it isn’t working:

If comboNames = “Marcus” Then listMarcusHours.AddItem txtHours.Text
Else
Beep
End If

comboNames is the combolist on main interface, listMarcusHours is the list I want to add it to (log), and txtHours is the hours textbox on the main interface… am I goin down the right path here? or is this the hard way? Plus, this isn’t working, I get the “Else without an If!” error, when there is clearly and If there, confused… ?!

gah - I just wrote a load and hit tab like a dufus as I was in code write mode. That’ll teach me, back to drinking. If no-one else has posted, I’ll give you some pointers later/tomorrow (UK time).

Welcome to TPR :wave:

DT. :wasted:

hey thanks Double,

I’m just really anxious to get this done, and I really usually don’t ask for help, because thats me, i’m stubborn, and like to try and find things out by trial and error, but this is a big project, and I need to know the best way to maker’her work, so thanks for any help, it’s greatly appreciated…

There are a number of ways to solve this sort of dilemma, based on the scalability of the application you are developing.

My gut instinct is saying to go with a simple write and read from text files or ini files, with each file being named after the value in the combobox.text

So something like


Private Sub cmdAdd_Click()

Dim strLog As String

Open App.Path + cmbName.Text For Input As #1
    strLog = Input$(LOF(1), 1)
Close #1

strLog = cmbName.Text + txtHours.Text + txtJob.Text + vbCrLf + strLog

Open App.Path + cmbName.Text For Output As #1
     Print #1, strLog
Close #1

End Sub

That would be my attack method for this - but I may have made it too simple.

The code you said was not working becase by putting the action on the same of line as the “If” block, asked and answered a question. The syntax should be;


If comboNames = "Marcus" Then 
     listMarcusHours.AddItem txtHours.Text
Else
     Beep
End If

I hope this gives you enough to go on :slight_smile:

DT.

Hello again, thanks for the help there, but I’ve got another question for ya…

Since i’m not real familiar with ini files and whatnot, I think I may use the code I had originally had, but here is the question…

Is it possible, in my ‘options’ menu, to have the ‘add staff member’ button create a new form (for loggin that user’s hours), and also add the code i’m using for each individual user when clicked as well?

Example:

I used the above code for the user ‘Marcus’, I would have the “add” button, when on his name, add the information to his form/log.

Is it possible for a button, when clicked, to add a whole new form for example, the user ‘kyle’, and also add in the code to the already existing forms so that when his name is highlighted/chosen, then it will add the information to the newly made ‘kyle’ log as well?

thanks again…

entirely possible - but from an architect side, what “hard” place are you storing your data ? I’m just concerned of you going a road too far. So, where is the historical data going to come from once the application has been closed ?

DT.

well, how about a possible simple install? placing a Folder in program files? or to a possible share directory so that it can be accessable from multiple computers at the school?

I think you may have missed my point. The installation directory is fine, folder in program files as per standard. Writing the entered data into a listview will mean when the application is closed and then restarted, the listview will be empty. Hence the suggestion to store the entered data into a text file as per the code above for “cmdAdd”. That code will generate a text file for every name that you put into the cmbBox.

The next question is answered by reading all the files in the “datastore” (text file directory), parsing the name of the text file and on form startup using a loop to add the text file names to the cmbBox.

A logic workflow of;

Open Application
App reads a “program files\app name\datastore” directory
Each filename stripped of the .txt and the name used to populate cmbBox
Click add data, app opens text file and adds data to start of file and saves
Click new member, app creates text file and refreshes the cmbbox

hth,

DT.

That… is just a great idea… Now I will be coding all of this soon, but i feel the need to use your time more :stuck_out_tongue: :wink:

I’ve never made an installation app before. Do I just create an EXE that when ran, creates the directory and puts the shortcuts to the actual program in the designated locations? I’m guessin that’s just a plain obvious question, so to ask what I really want to ask, what is the code for this? is there a “create” command or whatnot? Thanks again…

I use InnoSetup to deploy my applications, there are guides on the site for how to deploy the VB6 runtimes just in case, and any other files you use in the project (i.e. your datastore directory). The app for InnoSetup comes with a bundle of example projects - you should be able to pick it up from that. I would recommended getting ISTool pack and that really does make it very easy to use the compiler.

DT.

Hey man, I REALLY apprecaiate all the help, but i’m not understanding this Inno setup thing… I downloaded the latest version, but how exactly do use this to install MY application directories? Possible tutorial for this? I would donate to the site if so, if you have paypal that is :slight_smile:
thanks again…

edit:
I’m looking through the Inno help page, and all I see is delphi, and C++ compilation help… nothing VB6 related…

http://www.jrsoftware.org/iskb.php?vb

Firstly to be sure you need to distribute the VB6 runtimes as per the link above.

Then as your application you need to add to the files part in istool your .exe file and any datasource files you wish to distribute.
For an example;


Source: Built\MMC Lite.exe; DestDir: {app};

that will deploy the file relative to the .ixx script “built\MMC Lite.exe” to the application directory chosen by the user during setup.

Hope that helps - just got back from the pub :wasted:

DT.