Solved

how could I refer VB constant (enum) in C#

Posted on 2011-03-08
8
428 Views
Last Modified: 2013-12-17
I have a VB function Public Sub ShowMessage(ByVal message As String, Optional ByVal messageStyle As MsgBoxStyle = MsgBoxStyle.DefaultButton1) and I need to call it from C#. How could I submit the second parameter.  In VB, I can use MsgBoxStyle.Critical, but in C#, it would give me the error "the name MsgBoxStyle doesn't exist in context". Should I import a library? thanks.
0
Comment
Question by:Richard_XP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 12

Expert Comment

by:rgn2121
ID: 35072230
That is part of Microsoft.VisualBasic, so check and see if it is referenced....
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35072249
You'll have to include the Microsoft.VisualBasic assembly into your project.

MsgBoxStyle is a VB only enum, you would have made life simpler for yourself if you had stuck to the more general .Net MessageBoxIcon type for your parameter.
0
 
LVL 4

Author Comment

by:Richard_XP
ID: 35072275
I can not find MsgBoxStyle in Microsoft.VisualBasic, the only thing available is VBCodeProvider. thanks.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Assisted Solution

by:rgn2121
rgn2121 earned 100 total points
ID: 35072276
Actually...that might not exist at all...You will have to use MessageBox.Show(), which is the .Net version
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 400 total points
ID: 35072311
It is in there. Have you actually added a reference the the Microsoft.VisualBasic assembly, or have you only imported the namespace?
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 35072351
I can see it in the object Browser, but adding the assembly to Microsoft.VisualBasic does not allow you to get to MsgBox or the MsgBoxStyle Enums.  My guess is because this is really only a VB thing and not a .Net thing.  So using the MessageBox Class will allow for compatibility between VB and C#.
0
 
LVL 4

Author Closing Comment

by:Richard_XP
ID: 35072357
you are right, I need to add reference to microsoft.visualbasic first, then I can refer it. I will use messagebox instead
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 35072382
I stand corrected...Microsoft.VisualBasic.MsgBoxStyle is there... I still don't see MsgBox
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question