[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (2024)

  • Register
  • Help

  • Forum
    • New Posts
    • FAQ
    • Calendar
    • Forum Actions
      • Mark Forums Read
    • Quick Links
      • Today's Posts
      • View Site Leaders
  • What's New?
  • Advertiser Disclosure

  • Advanced Search
  • VBForums
  • Visual Basic
  • Visual Basic .NET
  • [RESOLVED] VB 6 - Duplicate Declaration in Current Scope

Results 1 to 4 of 4

  • Thread Tools
    • Show Printable Version
  • Display
    • Switch to Hybrid Mode
    • Switch to Threaded Mode
  1. Jul 7th, 2009,04:03 PM#1

    Jefftopia

    • View Profile
    • View Forum Posts

    [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (3)

    Thread Starter

    Addicted Member [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (4)

    Join Date
    Jun 2002
    Location
    Sunny Scottsdale Arizona
    Posts
    254

    [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (5) [RESOLVED] VB 6 - Duplicate Declaration in Current Scope

    I am attempting to dynamically dim a variable (i.e. create instance based on user selection).

    For example, based on the users selection from a combo box containing report names ("Report A", "Report B", "Report C", etc.), I would like to Dim a report variable (MyReport).

    Code:

    Select Case cboReportName.Text Case "Report A" Dim MyReport As New rptReportA Case "Report B" Dim MyReport As New rptReportB Case "Report C" Dim MyReport As New rptReportCEnd Select
    As expected, the code fails due to duplicate declaration in current scope.

    Suggestions appreciated.

    Last edited by Jefftopia; Jul 7th, 2009 at 05:51 PM.Reason: Mark as resolved.

    Reply With Quote

  2. Jul 7th, 2009,04:06 PM#2

    Negative0

    [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (7)

    PowerPoster 2.0 [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (8)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (9)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (10)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (11)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (12)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (13)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (14)

    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Duplicate Declaration in Current Scope

    Do all of the report objects inherit from a base class or do they implement an interface? If so, you could do something like this:

    Code:

    Dim myReport as Report Select Case cboReportName.Text Case "Report A" MyReport = New rptReportA Case "Report B" MyReport = New rptReportB Case "Report C" MyReport = New rptReportCEnd Select

    Reply With Quote

  3. Jul 7th, 2009,04:21 PM#3

    Campion

    • View Profile
    • View Forum Posts

    [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (17)

    Frenzied Member [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (18)[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (19)

    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: Duplicate Declaration in Current Scope

    [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (21) Originally Posted by Negative0

    Do all of the report objects inherit from a base class or do they implement an interface?

    The topic mentions VB6, of which inheritance doesn't exist. I suggest moving this to VB6.

    I would help, but I've lost my VB6 knowledge.

    From my burrow, 2 feet under.

    Reply With Quote

  4. Jul 7th, 2009,05:50 PM#4

    Jefftopia

    • View Profile
    • View Forum Posts

    [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (24)

    Thread Starter

    Addicted Member [RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (25)

    Join Date
    Jun 2002
    Location
    Sunny Scottsdale Arizona
    Posts
    254

    [RESOLVED]Re: VB 6 - Duplicate Declaration in Current Scope

    Thanks so much. With one minor alteration, your code worked perfectly:

    Code:

    Dim myReport as Report Select Case cboReportName.Text Case "Report A" Set MyReport = New rptReportA Case "Report B" Set MyReport = New rptReportB Case "Report C" Set MyReport = New rptReportCEnd Select

    Reply With Quote

Quick NavigationVisual Basic .NETTop

  • Site Areas
  • Settings
  • Private Messages
  • Subscriptions
  • Who's Online
  • Search Forums
  • Forums Home
  • Forums
  • Visual Basic
    1. Visual Basic .NET
      1. CodeBank - VB.net
    2. Visual Basic 6 and Earlier
      1. CodeBank - Visual Basic 6 and earlier
    3. TwinBASIC
      1. CodeBank - TwinBASIC
    4. Universal Windows Platform and Modern Windows Experience
    5. Xamarin
    6. Mobile Development
    7. ASP, VB Script
    8. Office Development
    9. Database Development
    10. Reporting
    11. API
    12. Games and Graphics Programming
      1. Game Demos
    13. COM and ActiveX
    14. Network Programming
    15. Visual Basic FAQs
    16. Slow Chat with the Microsoft Visual Basic team
  • .NET and More
    1. ASP.NET And ASP.NET Core
    2. Visual Basic .NET
    3. MVC .Net
    4. C#
    5. Microsoft Azure and Cloud Dev
    6. WPF, WCF, WF
    7. .NET Architecture and Design
    8. Silverlight
  • General
    1. General Developer Forum
    2. IoT, IoE, and Maker Forum
    3. Testers and Testing
    4. Application Testing
    5. Application Deployment
    6. Linux Development
    7. General PC
    8. VBForums Coding Contests
      1. Contest Entries
    9. Code It Better
    10. Maths Forum
  • Other Languages
    1. Other BASIC
    2. C and C++
    3. Java
    4. PHP
    5. XML, HTML, Javascript, Web and CSS
    6. jQuery
    7. Assembly
    8. Other Programming Languages
  • VBForums CodeBank
    1. CodeBank - Visual Basic .NET
    2. CodeBank - Visual Basic 6 and earlier
    3. CodeBank - ASP / ASP.NET / Blazor / MVC / Web API
    4. CodeBank - C#
    5. CodeBank - C++
    6. CodeBank - Java / J#
    7. CodeBank - PHP
    8. Codebank - Game Programming
    9. Codebank - Mobile Development
    10. CodeBank - JavaScript
    11. Codebank - Cascading Style Sheets (CSS)
    12. CodeBank - Other
  • VBForums UtilityBank
    1. UtilityBank - Utilities
    2. UtilityBank - IDE Add-Ins
    3. UtilityBank - Components
    4. UtilityBank - Tutorials
    5. UtilityBank - Other
  • Projects
    1. Project Requests
    2. Project Communication Area
  • Jobs
    1. Just VB Jobs
    2. Open Positions (Jobs)
    3. Looking for Work
  • Community
    1. Forum Feedback
    2. General Discussion / Chit Chat
      1. World Events
    3. Forum Test Area

«Previous Thread|Next Thread»

  • VBForums
  • Visual Basic
  • Visual Basic .NET
  • [RESOLVED] VB 6 - Duplicate Declaration in Current Scope

Posting Permissions

  • 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
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules

  • Contact Us
  • VB Forums
  • Top

Click Here to Expand Forum to Full Width

[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (29)

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.

All times are GMT -5. The time now is 03:37 AM.

[RESOLVED] VB 6 - Duplicate Declaration in Current Scope-VBForums (2024)

References

Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 5868

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.