-
September 18th, 2013, 05:25 AM
#1
[RESOLVED] Same listview on different forms
In a project with several forms i use a listview with the same contents on each form.
On form1 there is LvTijdvakken
On form2 there is LvTijdvakken and so on.
Is it possible to fill the LvTijdvakken on the different forms with one routine ?
F.i. Call FillLvTijdvakken(form1)?
Herman
Last edited by HermanTabbert; September 18th, 2013 at 08:40 AM.
-
September 19th, 2013, 01:57 AM
#2
Re: Same listview on different forms
Yes, you have the right idea. You should just provide a parameter to your FillLvTijdvakken routine, I'm typing off the cuff here, so let us see :
Code:
Public Sub FillLvTijdvakken(frm as Form)
.....
frm.LvTijdvakken.LitsItems.Add(Whatever data) 'fill appropriate ListView here
End Sub
Call FillLvTijdvakken(Form2) ' call sub here with correct form ( meybe even use Me here as well )
I hope it helps!
-
September 19th, 2013, 08:59 AM
#3
Re: Same listview on different forms
You could take it another step and pass the listview to the sub instead fo the form
Place the sub in a module
Code:
Public Sub FillListView(TheList as ListView)
With TheList
'Code to add items to the list
' i.e. .ListItems.Add ......
End With
End Sub
'to call the sub then in your form code you would use something like
Code:
FillListView LvTijdvakken
Or if calling it from somewhere other than the form where it resides you would use
Code:
FillListView Form2.LvTijdvakken
or
Code:
FillListView Form1.LvTijdvakken
Note the Call keyword is not required in VB.
I am really surprised how many people I see using it on the forums. I guess somewhere they still teach this but it has not been needed for at least 20 years now.
Always use [code][/code] tags when posting code.
-
September 21st, 2013, 06:46 AM
#4
Re: Same listview on different forms
Hannes and Datamiser thanks for your help.
This is what works fine for me.
Greetings from Holland,
Herman
Code:
Public Sub VulDeTijdvakken(Frm As Form)
Close #12
TijdvakBestand = "c:\hatacom\source\lonen_2014\projecten\adm001\tijdvak12.13"
Open TijdvakBestand For Random As #1 Len = Len(TV)
For X = 1 To 8
Get #1, X, TV
With Frm
.LvTijdvakken.ListItems.Add , , TV.Periode
.LvTijdvakken.ListItems(.LvTijdvakken.ListItems.Count).SubItems(1) = TV.LoontijdVakBegin
.LvTijdvakken.ListItems(.LvTijdvakken.ListItems.Count).SubItems(2) = TV.LoontijdVakEind
Tempbestand = "c:\hatacom\source\lonen_2014\projecten\adm001\lonen" & Format(X, "##00") & "." & "13"
' loonberekening
Temp = Format(FileDateTime(Tempbestand), "dd-mm-yyyy")
.LvTijdvakken.ListItems(.LvTijdvakken.ListItems.Count).SubItems(3) = Temp
' Aangifte
Tempbestand = "c:\hatacom\source\lonen_2014\projecten\adm001\aangifte" & Format(X, "##00") & "13." & "xml"
Temp = Format(FileDateTime(Tempbestand), "dd-mm-yyyy")
.LvTijdvakken.ListItems(.LvTijdvakken.ListItems.Count).SubItems(4) = Temp
End With
Next X
End Sub
end code
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|