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.


Contacts and List Boxes


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-21-2008, 06:39 AM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default Contacts and List Boxes

Okay,

I'm a newbie here. I've done some searching on the forum and have not quite found the answer that I am looking for.

Here is what I want to accomplish.

1. I have 2 list boxes on my form.
2. When I Load the form, I want ListBox1 to display all PIM Contacts that have a mobile number and omit any that do not.
3. When I click/tap on an entry in ListBox1, ListBox2 will display a list of mobile numbers associated with the ListBox1 selection.
4. When I click/tap on the entry in ListBox2 that I want, I want to grab that phone number and assign it to a variable so that it can be written into a file or registry entry for later use.

Here is the code I am using so far:

LIST BOX 1
-------------------------------------------------
Sub cboButtons_SelectionChanged (Index, Value)
Dim MTL
Contact.New1
PimCol.New1("Contacts")
ListNumbers.Clear
ListContacts.Clear
For I = 0 To PimCol.Count -1
Contact.Value = PimCol.GetItem(I)
MTL = StrLength(Contact.MobileTelephoneNumber)
If MTL > 0 Then
ListContacts.Add(Contact.Nickname & "-" & Contact.LastName & "," & Contact.FirstName)
End If
Next
ListContacts.Refresh
End Sub

LIST BOX 2
------------------------------------------
Sub ListContacts_SelectionChanged (Index, Value)
Contact.New1
PimCol.New1("Contacts")
PimCol.GetItem(ListContacts.SelectedIndex)
ListNumbers.Clear
Contact.Value = PimCol.GetItem(ListContacts.SelectedIndex)
ListNumbers.Add (ListContacts.SelectedIndex & "/" & Contact.LastName & "/" & Contact.MobileTelephoneNumber)
ListNumbers.Refresh
End Sub


I could really use some help.

Thanks

Dave ///
Reply With Quote
  #2 (permalink)  
Old 01-21-2008, 06:54 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 482
Default

Hi Oran,

For ListBox 2 I don't think that you need to create a new instance of Contacts and PimCol as they have already been created when you did ListBox 1.
Try removing these two lines and see what happens.


PS Welcome to the Forum

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
  #3 (permalink)  
Old 01-21-2008, 07:09 AM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default

RandomCoder,

Thanks for the blisteringly fast reply! I zapped the two entries you suggested and the list boxes still appear to be out of sync with each other. List2 appears to be 'behind' list 1 in the index or something.... really wierd.

PS - Thanks for the warm welcome. I really love this OS language -- puts eVB to shame -- really simple to understand and use. Slight syntax shift from my normal vb use but WAY better than the competition out there.

Dave ///
Reply With Quote
  #4 (permalink)  
Old 01-21-2008, 09:52 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 482
Default

Sorry for the delay, I'm now at work and can only assist during break times.
You say that the problem is that your numbers are out of sync with the names?

This might be caused by having contact names in the list that do not have numbers associated with them.
I'd be inclined to pull all the contact names and numbers into a text box to see that the data I'm receivng is as expected.
From there you may be able to see where it is going wrong.

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
  #5 (permalink)  
Old 01-21-2008, 10:04 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 482
Default

On second thoughts, try this...

Code:
Sub ListContacts_SelectionChanged (Index, Value)
ListNumbers.Clear
Contact.Value = PimCol.GetItem(Value)
ListNumbers.Add (ListContacts.SelectedIndex & "/" & Contact.LastName & "/" & Contact.MobileTelephoneNumber)
ListNumbers.Refresh 
End Sub
In place of your ListBox 2 code.

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
  #6 (permalink)  
Old 01-22-2008, 02:00 AM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default

RandomCoder....

ARGH.... no dice dude. Tried everything I can think of. I'm about to scrap the project. I've tried just about everyting I know....

Need 2 lists boxes... one for listing contacts, once listed, then click the entry and display the mobile number in the other... sounds really simple but amazingly enough, I can write a space shuttle launch program before I can manage the PIM's....

Dave ///
Reply With Quote
  #7 (permalink)  
Old 01-22-2008, 06:18 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 482
Default

Programmers don't quit so easily

The outlook library is one that I've only just started to show an interest in as I want to be able to catch and store messages from certain numbers.
Keep persevering, so far you've found several ways that it can't be done but sooner or later you discover one of the many ways that it can be done.

I'll have a little go at doing this myself and post here soon

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 01-22-2008, 11:34 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 482
Smile My Attempt

@ Dave,

I don't like to see anyone struggling when I can be of help, so here is my attempt at what you need.
It only works on the Device as Outlook is really only intended for the device.

Hope that you can now tailor it to your own requirements


PS. I've attached all the files you need including .dll's which we tend not to do as you already have them. I just wanted to make sure that you were able to understand how it all worked.

Regards,
RandomCoder
Attached Files
File Type: zip PIM-Contacts.zip (13.9 KB, 16 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
  #9 (permalink)  
Old 01-22-2008, 02:42 PM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default

RC -

Well, I just want to go on the record for saying that you are awesome! That works great. I can see where I need to take it from here for my project. Your assistance is highly appreciated. I consider myself to be the same. I can't stand to see people struggle with something -- provided I can see that he or she has made an attempt to do it on their own. You are the definition of what these forums are all about.

You took the time to help out a noob (forum and this app wise) and spend the time to put me on the path that I need to be on.

KUDOS TO YOU!

Kind Regards,

Dave ///
Reply With Quote
  #10 (permalink)  
Old 01-22-2008, 07:08 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 482
Default

Thanks, but comments like that will surely make me big headed

Once I attempted the problem for myself I saw where the difficulty was.
Because you were stripping out the contacts that hadn't got a number, this meant that the Items in the ListBox containing the names was no-longer concurrent with the PIM Items.
You could also try using FindItem to locate the last name of the contact etc. But as this requires some string manipulation and relies on contacts having a unique last name (not always the case when you look at Aunts, Uncles and Cousins etc), which is why I deemed an ArrayList to be a much more simple solution.
Also note that you only need to initialise the objects once, and if required you can dispose of them when you've finished with them.

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
drive, file list boxes scott93727 Basic4ppc Wishlist 0 06-22-2008 01:35 AM
Problem with Contacts willisgt Questions & Help Needed 6 05-14-2008 03:26 PM
Area Selection by combo boxes mozaharul Questions & Help Needed 4 04-30-2008 04:36 AM
Outlook library and contacts list lancaster Questions & Help Needed 2 02-08-2008 09:26 AM
Treeview and check-boxes BjornF Questions & Help Needed 2 06-26-2007 03:45 PM


All times are GMT. The time now is 06:10 PM.


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