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.


Problem with Contacts


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-13-2008, 02:44 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default Problem with Contacts

This bit of code crashes for some strange reason:

Code:
	Contact.New1
	ContactsCollection.New1( "Contacts" )

	ContactsCollection.SortItems( "LastName", false )

	For i = 0 To ContactsCollection.Count - 1

		Contact.Value = ContactsCollection.GetItem(i)
		
		ListBox1.Add( Contact.FirstName & " " & Contact.LastName )


		website	= contact.WebPage

                          msgbox( website )

	Next

The problem is on the line:

Code:
		website	= contact.WebPage
(I'm sure because if I comment it out, it works.)

Any ideas?


Gary

__________________
PC: Windows XP Pro SP2 / Basic4PPC v6.3
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #2 (permalink)  
Old 05-13-2008, 02:54 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,633
Default

What does the error message say?
Reply With Quote
  #3 (permalink)  
Old 05-13-2008, 03:06 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

I must be losing my mind - i should have included this in the original post.

The error message says:
'An error occurred on sub (sub name)

NullReferenceException

Continue? (y/n)'


Gary

__________________
PC: Windows XP Pro SP2 / Basic4PPC v6.3
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #4 (permalink)  
Old 05-13-2008, 03:09 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,633
Default

Try to add check for null values:
Code:
If Not (IsNull(contact.WebPage)) Then website = contact.WebPage else website = ""
Reply With Quote
  #5 (permalink)  
Old 05-13-2008, 03:16 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default Problem persists

I made the change you suggested, but the problem persists.

The Outlook.dll version is 1.0.2900.27127.
The OutlookDesktop.dll version is 1.0.2900.27246.

The entire program is attached.


Gary
Attached Files
File Type: sbp export.sbp (7.7 KB, 2 views)
__________________
PC: Windows XP Pro SP2 / Basic4PPC v6.3
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #6 (permalink)  
Old 05-13-2008, 03:58 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,633
Default

Yes, IsNull will not help here.
Contact.WebPage will only work properly if the contact's webpage field is a valid URL.
The "http://" prefix is also required.
This is a limitation of the underlying .Net CF method.
The only workaround I can think of is to catch this error:
Code:
        spouse                = contact.Spouse
        suffix                = contact.Suffix
        title                = contact.Title
        website                = GetWebsite
        table1.AddRow(... )
    Next
End Sub

Sub GetWebsite
    ErrorLabel(errGetWebsite)
    Return contact.WebPage
errGetWebsite:
    Return ""
End Sub
Reply With Quote
  #7 (permalink)  
Old 05-14-2008, 03:26 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

Aha! That did the trick!

Thanks!
__________________
PC: Windows XP Pro SP2 / Basic4PPC v6.3
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
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
Lookup Contacts using a listbox thartung Questions & Help Needed 9 02-27-2008 09:16 AM
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
Access to Outlook contacts Big JR Code Samples & Tips 3 09-26-2007 10:16 AM


All times are GMT. The time now is 01:14 PM.


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