Good morning everybody:
I am attempting to populate a listview control on Form Load()
and I get a Run-Time Error: 380 - Invalid property value. Below is the line to generates the error:

lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address

Below is alos my entire FormLoad module:

Private Sub Form_Load()
Set OutlookApp = New Outlook.Application
Set OutlookMailItem = OutlookApp.CreateItem(olMailItem)
Set OutlookNameSpace = OutlookApp.GetNamespace("MAPI")

lvw.ListItems.Clear

For Each OutlookAddressList In OutlookNameSpace.AddressLists
    For Each OutlookAddressEntry In OutlookAddressList.AddressEntries
        lvw.ListItems.Add , , OutlookAddressEntry.Name
        lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address
        lvw.ListItems(lvw.ListItems.Count).SubItems(2) = OutlookAddressEntry.ID
        lvw.ListItems(lvw.ListItems.Count).Tag = OutlookAddressEntry.ID
    Next
Next
End Sub

Any help will b greatly appreciated
Thanks,
tgifgemini.

try
.count -1
when there are 3 entries ,count would be 3, but the last index is 2 since it starts at 0

I changed my codes to:

lvw.ListItems.Add , , OutlookAddressEntry.Name
        lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address
        lvw.ListItems(lvw.ListItems.Count).SubItems(2) = OutlookAddressEntry.ID
        lvw.ListItems(lvw.ListItems.Count).Tag = OutlookAddressEntry.ID

But I still get compile error: 380 - Invalid property value.
sorry for the inconveniences.
tgifgemini.

Sorry my mistake. I changed my codes to:

lvw.ListItems.Add , , OutlookAddressEntry.Name
        lvw.ListItems(lvw.ListItems.Coun-1t).SubItems(1) = OutlookAddressEntry.Address
        lvw.ListItems(lvw.ListItems.Count-1).SubItems(2) = OutlookAddressEntry.ID
        lvw.ListItems(lvw.ListItems.Count-1).Tag = OutlookAddressEntry.ID

But I got the same compile error: 380-invalid property value.
tgifgmini.

Now I got the above title error on the code below:

lvw.ListItems(lvw.ListItems.Count - 1).SubItems(1) = OutlookAddressEntry.Address

Thanks
tgifgemini.

I finally found a solution for switching from active form to another form and back again. Here it is:

In the code for form1
<Code> Form_Unload(-1)
set form1=Nothing
Load (form2)
form2.visible=True
</Code>

In the code for form2
<Code> Form_Unload(-1)
set form2=Nothing
Load (form1)
form1.visible=True
</Code>

The switching is quite smooth and the memory is cleared for the unloaded form.

Good Luck,
Suresh

commented: Irrelevant to topic. +0

Try starting at Subitems(0) on your listview

hi, i am developing a personal firewall application with Visual Basic 6.0. Basically all the coding been done. and yet i had this run time error 380 and line of code which occur error highlighted with bright yellow color attached as below:

Item.Text = mdlFile.GetFileDescription(Connection(i).Filename)

can anyone please help me with this? helps is kindly appreciated.

p/s: the personal firewall system i proposed for my diploma final year project. hope the system can run well thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.