Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Lookup Contacts using a listbox


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-25-2008, 03:54 AM
thartung's Avatar
Newbie
 
Join Date: Feb 2008
Location: Colorado Springs, CO
Posts: 4
Default Lookup Contacts using a listbox


I am trying to learn how to create a listbox that is populated by the PIM contacts, and being a noob, I am a bit confused. I have found some examples that show how to add the contacts collection and so forth, but I am not sure how to extact the selected item in the list. So far this is what I have:

form2.show
sendlist.New1
ContactsCollection.New1("Contacts")
ContactsCollection.SortItems("LastName",false) 'sorts the contacts using the last name field.
For i = 0 To ContactsCollection.Count - 1
Contact.Value = ContactsCollection.GetItem(i)
listbox1.Add(Contact.LastName & " " & Contact.firstName) 'Add the contact's first and last name to ListBox1.
Next
Contact.Value = ContactsCollection.GetItem(listbox1.SelectedIndex)

It errors out on the last line. Error says object reference not set

Thank you for any help provided
Reply With Quote
  #2 (permalink)  
Old 02-25-2008, 08:25 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,845
Default

What is sendlist?
Did you add the ContactsCollection object and the Contact object (with Tools - Add Object)?
You are also missing Contact.New1 in the beginning.
Reply With Quote
  #3 (permalink)  
Old 02-25-2008, 09:17 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 452
Default

This might help, I did it for someone else asking a very similar question.
It only shows contacts that have a mobile number listed.
Modify it to your own needs,

PS don't forget to add the Outlook.dll's to the working directory.

Regards,
RandomCoder
Attached Files
File Type: sbp PIM Collection.sbp (1.7 KB, 18 views)
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 02-26-2008, 02:41 AM
thartung's Avatar
Newbie
 
Join Date: Feb 2008
Location: Colorado Springs, CO
Posts: 4
Default

Thank you for the code. I loaded it on my device making sure the outlook.dll was in the working directory. When I run it on my device the listbox "Select Name" and "Mobile Number" are blank. No errors, but I would have expected to see a list of my contacts with a mobile number. I realize when running on the desktop they would be blank because of the "dummy" dll, but shouldn't I see something on the device?
Reply With Quote
  #5 (permalink)  
Old 02-26-2008, 02:48 AM
thartung's Avatar
Newbie
 
Join Date: Feb 2008
Location: Colorado Springs, CO
Posts: 4
Default

I just thought..... I have basic4PPC and all my sample code on my storage card. Could this be a problem?? I have been able to successfully run other samples
Reply With Quote
  #6 (permalink)  
Old 02-26-2008, 05:17 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,845
Default

I don't think that the storage card is the problem.
Please try the attached example.
Attached Files
File Type: sbp Contacts.sbp (804 Bytes, 23 views)
Reply With Quote
  #7 (permalink)  
Old 02-26-2008, 11:09 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 452
Default

I'm sorry to hear that you had problems with the code.
Is it possible that you have a blank entry within your contacts?
Because the listbox is set to a height of only one entry, it may be that the box is populated but just showing the blank entry, try scrolling down.
As it didn't error I would guess that it is working, you could also try making the listbox larger.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 02-27-2008, 02:02 AM
thartung's Avatar
Newbie
 
Join Date: Feb 2008
Location: Colorado Springs, CO
Posts: 4
Default

Thank you for the code Erel. This snippet works, yet the example that RandomCoder provided still doesn't seem to show any contacts even after I made the listbox larger. Not a big deal. I appreciate the time both of you spent helping me.

Thanks again!!
Reply With Quote
  #9 (permalink)  
Old 02-27-2008, 06:50 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,845
Default

RandomCoder's example shows only contacts which have a MobilePhoneNumber.
I've changed his example to show all contacts.
Reply With Quote
  #10 (permalink)  
Old 02-27-2008, 09:16 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 452
Default

Sorry for the confusion caused, but I did state that it selects only contacts having a mobile number.
If loading all contacts regardless of the contact details then there is no need to keep track of the index as this will be unaltered.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Contacts willisgt Questions & Help Needed 6 05-14-2008 03:26 PM
Outlook library and contacts list lancaster Questions & Help Needed 2 02-08-2008 09:26 AM
Contacts and List Boxes Oran Questions & Help Needed 9 01-22-2008 07:08 PM
Listbox difficulties. dan kabestan Questions & Help Needed 2 12-15-2007 06:24 PM
Access to Outlook contacts Big JR Code Samples & Tips 3 09-26-2007 10:16 AM


All times are GMT. The time now is 07:37 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0