MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Weird problem with MapPoint shapes and Combo Boxes

This is a discussion on Weird problem with MapPoint shapes and Combo Boxes within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Something really weird is happening when I try to add the name of a shape to a combo box using ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-23-2003
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Weird problem with MapPoint shapes and Combo Boxes

Something really weird is happening when I try to add the name of a shape to a combo box using VB 6.0. Below is an example that reproduces the error. I created a single form with one command button and one combo box (cmbTest) then attached the following code to the command button. g_oApp was previously attached to the MapPoint object.

Code:
Private Sub Command2_Click()
    Dim oMap As MapPoint.Map
    Dim oShape As MapPoint.Shape
    
    Set oMap = g_oApp.ActiveMap
    
    oMap.FindResults("Pacific Ocean")(1).GoTo

    Dim locLA, locTokyo As MapPoint.Location
    Set locLA = oMap.FindResults("Los Angeles, California")(1)
    Set locTokyo = oMap.FindResults("Tokyo, Japan")(1)

    ' Create and name the shape
    Set oShape = oMap.Shapes.AddLine(locLA, locTokyo)
    oShape.Name = "Tokyo Route"
    
    Me.cmbTest.AddItem oShape.Name

End Sub
You would think that "Tokyo Route" would appear in the combo box.. but instead I get "T". I can't figure it out. If I do a "MsgBox oShape.Name" I get the full name but the combo box only shows the first letter. I have found a work around but it is very annoying and doesn't make any sense.


Code:
Private Sub Command2_Click()
    Dim oMap As MapPoint.Map
    Dim oShape As MapPoint.Shape
    Dim iNameA, iNameB As String

    Set oMap = g_oApp.ActiveMap
    
    oMap.FindResults("Pacific Ocean")(1).GoTo

    Dim locLA, locTokyo As MapPoint.Location
    Set locLA = oMap.FindResults("Los Angeles, California")(1)
    Set locTokyo = oMap.FindResults("Tokyo, Japan")(1)

    ' Create and name the shape
    Set oShape = oMap.Shapes.AddLine(locLA, locTokyo)
    oShape.Name = "Tokyo Route"
    
    iNameA = mpShape.Name
    iNameB = iNameA  
    Me.cmbTest.AddItem iNameB

End Sub
Can anyone else confirm this. Is it just my computer. I suspect there is some weird compilation error. Or am I just missing something.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 03-23-2003
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
I ran your code (the first sample) and I got "Tokyo Route" in the combo box. I don't know what to tell you? Sorry...
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 03-23-2003
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Quote:
Originally Posted by John Meyer
I ran your code (the first sample) and I got "Tokyo Route" in the combo box. I don't know what to tell you? Sorry...
What version of VB are you using?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 03-23-2003
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
VB 6.0
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 03-24-2003
Junior Member
Yellow Belt
 
Join Date: Mar 2003
Posts: 12
Weird behavior

This may help explain some weird behavior:

Dim iNameA, iNameB As String

does not declare two variables of type String. Instead, iNameA has actually declared as a variant. Unlike other languages, VB 6 does not interpret a declaration like the following

Dim i, j, k as Integer

to be a declaration of 3 integers. Instead, "i" and "j", since they are not explicitly assigned a type, are automatically typed as variants. In effect, the code above is equivalent to

Dim i
Dim j
Dim k as integer.

You can check out what I am saying with the following code:

Public Sub Test()

Dim i as Variant
Dim j, k as integer

Debug.Print TypeName(i)
Debug.Print TypeName(j)
Debug.Print TypeName(k)

End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 03-24-2003
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Re: Weird behavior

Quote:
Originally Posted by Bob Chase
This may help explain some weird behavior:

Dim iNameA, iNameB As String

does not declare two variables of type String. Instead, iNameA has actually declared as a variant. Unlike other languages, VB 6 does not interpret a declaration like the following

Dim i, j, k as Integer

to be a declaration of 3 integers. Instead, "i" and "j", since they are not explicitly assigned a type, are automatically typed as variants. In effect, the code above is equivalent to

Dim i
Dim j
Dim k as integer.

You can check out what I am saying with the following code:

Public Sub Test()

Dim i as Variant
Dim j, k as integer

Debug.Print TypeName(i)
Debug.Print TypeName(j)
Debug.Print TypeName(k)

End Sub
That does help somewhat. It looks to me that for some odd reason my version of VB (or it could be MapPoint) is returning strange names for the shapes. Coping the shapes name into a variant seams to correct the problem. So the following code works but I still don't know what is wrong with my shape names.

Code:
Private Sub Command2_Click()
    Dim oMap As MapPoint.Map
    Dim oShape As MapPoint.Shape
    Dim iNameA As Variant
    
    Set oMap = g_oApp.ActiveMap
    
    oMap.FindResults("Pacific Ocean")(1).GoTo

    Dim locLA, locTokyo As MapPoint.Location
    Set locLA = oMap.FindResults("Los Angeles, California")(1)
    Set locTokyo = oMap.FindResults("Tokyo, Japan")(1)

    ' Create and name the shape
    Set oShape = oMap.Shapes.AddLine(locLA, locTokyo)
    oShape.Name = "Tokyo Route"
    
    iNameA = oShape.Name
    Me.cmbTest.AddItem iNameA

End Sub
BTW... John are you using SP5?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 03-24-2003
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
yes, SP5

Try using the ActiveX control and see if it makes a difference.

Code:
Dim oMap As MapPointctl.Map
Set oMap = MappointControl1.ActiveMap
Dim oShape As MapPointctl.Shape
    
oMap.FindResults("Pacific Ocean")(1).GoTo

Dim locLA, locTokyo As MapPointctl.Location
Set locLA = oMap.FindResults("Los Angeles, California")(1)
Set locTokyo = oMap.FindResults("Tokyo, Japan")(1)

' Create and name the shape
Set oShape = oMap.Shapes.AddLine(locLA, locTokyo)
oShape.Name = "Tokyo Route"
    
Me.cmbTest.AddItem oShape.Name
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
boxes, combo, mappoint, problem, shapes, weird


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

BB 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
Mapping PO Boxes MeliDe MapPoint 2006/2009 Discussion 1 10-21-2005 02:42 PM
Fill the shapes with colors problem vidyakulkarni MapPoint 2006/2009 Discussion 4 09-28-2004 10:05 AM
Copying Worksheet with Combo Box Anonymous MapPoint 2006/2009 Discussion 0 07-20-2004 05:13 PM
Hiding Boxes around Label shapes andrem MapPoint 2006/2009 Discussion 3 09-25-2003 01:09 PM
Text Boxes ClactonEssex Wish List 0 12-10-2002 08:52 AM


All times are GMT -5. The time now is 04:17 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54