Book a Demo

Author Topic: help with custom view - AddTab  (Read 4351 times)

jumbie

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
help with custom view - AddTab
« on: February 25, 2007, 05:00:11 am »
I have this problem with custom view created by my own user control, please help me:

In VB 6.0, this code does not work:

Dim lMyUctrl As Project1.UserControl1

Set lMyUctrl = Repository.AddTab("Hello", "Project1.UserControl1")

The tab is created in EA with name “Hello” correctly, but setting the returned object from AddTab into lMyUctrl is raising run-time error “Type mismatch”.

Can You help me with a little advice?

Thanks.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: help with custom view - AddTab
« Reply #1 on: February 26, 2007, 02:56:38 pm »
Perhaps try assigning to a regular 'Object' first, then try casting it later.  See if that makes any difference.

Dim objTab
Set objTab = Repository.AddTab("Hello", "Project1.UserControl1")

If Not objTab Is Nothing Then
   Dim lMyUctrl As Project1.UserControl1
   Set lMyUctrl = objTab
End If

jumbie

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: help with custom view - AddTab
« Reply #2 on: February 26, 2007, 03:40:50 pm »
...the row:

Set lMyUctrl = objTab

in your example is raising the same error Type mismatch.
The problem is only delayed  :)...

Now I work with object lMyUctrl without downcast (i.e. as Object), I call its methods from interface UserControl1 and it is working (!), but of course without intellisense in VB 6.0 => I must write code by this "untyped unpleasant" way.

Changing interface to UserControl1 is not working and I dont know why...  







Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: help with custom view - AddTab
« Reply #3 on: February 26, 2007, 06:12:35 pm »
In the "Repository" documentation I just noticed it says that the AddTab method returns an IUnknown pointer, which may be the problem.  Try searching through google for information on using IUnknown in VB6.  Not sure how best to do it myself unfortunately.  :-[

My only other suggestion is to temporarily put "As Project1.UserControl1" on the end of the Dim statement to get back your Intellisense while writing code, then comment it out again before running.

Hope this helps.