car'a'carn
17th November 2006, 05:07 PM
This is a school thingy and i will get points on this (so if you think this is against the rules, don't reply). We've been making a little program lately. it has to put items in a listbox, the items are given in or calculated. For some reason I can't figure out how to make both the OPEN and the ADD LINE to work at the same time. The following will be the code I used for the commands. I hope one of you guys can explain to me what I'm doing wrong.
Public Function Omzetting(ByVal strnaam As String, ByVal strvoornaam As String, ByVal strnederlands As String, ByVal strfrans As String, ByVal strwiskunde As String, ByVal strinformatica As String, ByVal strgemiddelde As String, ByVal strtotaal As String) As String
Omzetting = (strnaam & Space(15 - Len(strnaam)) & strvoornaam & Space(15 - Len(strvoornaam)) & strnederlands & Space(5 - Len(strnederlands)) & strfrans & Space(5 - Len(strfrans)) & strwiskunde & Space(5 - Len(strwiskunde)) & strinformatica & Space(5 - Len(strinformatica)) & strtotaal & Space(8 - Len(strtotaal)) & strgemiddelde)
End Function
Private Sub cmdToevoegen_Click()
Dim line As String
line = Omzetting(txtnaam.Text, txtvoornaam.Text, txtnederlands.Text, txtFrans.Text, txtinformatica.Text, txtwiskunde.Text, txtTotaal.Text, txtGemiddelde.Text)
If txtTotaal = "" Or txtGemiddelde = "" Then
MsgBox "eerst Berekenen", vbCritical, "fout"
Else:
lstlijst.AddItem line
txtnaam.Text = ""
txtvoornaam.Text = ""
txtnederlands = ""
txtFrans = ""
txtinformatica = ""
txtwiskunde = ""
End If
End Sub
Private Sub cmdopslaan_Click()
If cdlopensave.FileName = "" Then
cdlopensave.ShowSave
End If
Dim intteller As Integer
Open cdlopensave.FileName For Output As #1
For intteller = 0 To lstlijst.ListCount - 1
Write #1, RTrim(Left(lstlijst.List(intteller), 100))
Next intteller
Close #1
End Sub
Private Sub cmdopenen_Click()
cdlopensave.ShowOpen
Dim strnaam As String
Dim strvoornaam As String
Dim strnederlands As String
Dim strfrans As String
Dim strinformatica As String
Dim strwiskunde As String
Dim strtotaal As String
Dim strgemiddelde As String
Open cdlopensave.FileName For Input As #1
Do While Not EOF(1)
Input #1, strnaam
lstlijst.AddItem Omzetting(strnaam, strvoornaam, strnederlands, strfrans, strwiskunde, strinformatica, strgemiddelde, strtotaal)
Loop
Close #1
End Sub
That's what I got this far. I think the problem is either in the public function or the command to open.
Public Function Omzetting(ByVal strnaam As String, ByVal strvoornaam As String, ByVal strnederlands As String, ByVal strfrans As String, ByVal strwiskunde As String, ByVal strinformatica As String, ByVal strgemiddelde As String, ByVal strtotaal As String) As String
Omzetting = (strnaam & Space(15 - Len(strnaam)) & strvoornaam & Space(15 - Len(strvoornaam)) & strnederlands & Space(5 - Len(strnederlands)) & strfrans & Space(5 - Len(strfrans)) & strwiskunde & Space(5 - Len(strwiskunde)) & strinformatica & Space(5 - Len(strinformatica)) & strtotaal & Space(8 - Len(strtotaal)) & strgemiddelde)
End Function
Private Sub cmdToevoegen_Click()
Dim line As String
line = Omzetting(txtnaam.Text, txtvoornaam.Text, txtnederlands.Text, txtFrans.Text, txtinformatica.Text, txtwiskunde.Text, txtTotaal.Text, txtGemiddelde.Text)
If txtTotaal = "" Or txtGemiddelde = "" Then
MsgBox "eerst Berekenen", vbCritical, "fout"
Else:
lstlijst.AddItem line
txtnaam.Text = ""
txtvoornaam.Text = ""
txtnederlands = ""
txtFrans = ""
txtinformatica = ""
txtwiskunde = ""
End If
End Sub
Private Sub cmdopslaan_Click()
If cdlopensave.FileName = "" Then
cdlopensave.ShowSave
End If
Dim intteller As Integer
Open cdlopensave.FileName For Output As #1
For intteller = 0 To lstlijst.ListCount - 1
Write #1, RTrim(Left(lstlijst.List(intteller), 100))
Next intteller
Close #1
End Sub
Private Sub cmdopenen_Click()
cdlopensave.ShowOpen
Dim strnaam As String
Dim strvoornaam As String
Dim strnederlands As String
Dim strfrans As String
Dim strinformatica As String
Dim strwiskunde As String
Dim strtotaal As String
Dim strgemiddelde As String
Open cdlopensave.FileName For Input As #1
Do While Not EOF(1)
Input #1, strnaam
lstlijst.AddItem Omzetting(strnaam, strvoornaam, strnederlands, strfrans, strwiskunde, strinformatica, strgemiddelde, strtotaal)
Loop
Close #1
End Sub
That's what I got this far. I think the problem is either in the public function or the command to open.