Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks

I know nothing about c# but I got sample from Microsoft for datagridviewcustomcolumn which is written in c#. I have used web utilities to convert the code. However, a small segment of the converted code did no turn out well,

I should therefore be very grateful if anyone converts this block of code to vb for me. The code is shown below:

C#


C#
//   Quick routine to convert from DataGridViewTriState to boolean.
        //   True goes to true while False and NotSet go to false.
        protected static bool BoolFromTri(DataGridViewTriState tri)
        {
            return (tri == DataGridViewTriState.True) ? true : false;
        }



        //  Routine to convert from boolean to DataGridViewTriState.
        private static DataGridViewTriState TriBool(bool value)
        {
            return value ? DataGridViewTriState.True
                         : DataGridViewTriState.False;
        }
Posted

 
Share this answer
 
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]. Try the above link to convert your C# to VB
 
Share this answer
 
Comments
noblepaulaziz 7-May-12 9:08am    
I used the utility but the vb compiler underline the vb version as error.
The vb version shown here:


' Quick routine to convert from DataGridViewTriState to boolean.
' True goes to true while False and NotSet go to false.
Protected Shared Function BoolFromTri(tri As DataGridViewTriState) As Boolean
Return If((tri = DataGridViewTriState.[True]), True, False)
End Function



' Routine to convert from boolean to DataGridViewTriState.
Private Shared Function TriBool(value As Boolean) As DataGridViewTriState
Return If(value, DataGridViewTriState.[True], DataGridViewTriState.[False])
End Function

Thanks
You are using short circuit if statements in your code.
You need to convert them into the VB equivalent syntax.

Here is an example
return If(tri = DataGridViewTriState.True, True, False))

You can try the second one on your own.
 
Share this answer
 
download from this link.it's a standalone Code Converter
www.download25.com/install/convert-net-20.html[^]
 
Share this answer
 
Hey Freind ,
There are lot of conversion tool in market online but please be careful that they are not 100% reliable :) especially in complex projects
- Ambesha
 
Share this answer
 
Comments
noblepaulaziz 7-May-12 9:10am    
Thank you
Ambesha 17-May-12 1:52am    
Welcome
Nikhil_S 16-May-12 0:55am    
true.but the one i mentioned is free and reliable.just try if u don't like it uninstall.
Ambesha 17-May-12 1:55am    
True Freind, I have my own Microsoft team senario where we will convert existing VB project to C#. The application is complex having 5000+ lines of code and more then 150 external dll refrence which lead to conversion failed! :(
VB
'   Quick routine to convert from DataGridViewTriState to boolean.
'   True goes to true while False and NotSet go to false.
Protected Shared Function BoolFromTri(tri As DataGridViewTriState) As Boolean
    Return If((tri = DataGridViewTriState.[True]), True, False)
End Function



'  Routine to convert from boolean to DataGridViewTriState.
Private Shared Function TriBool(value As Boolean) As DataGridViewTriState
    Return If(value, DataGridViewTriState.[True], DataGridViewTriState.[False])
End Function
 
Share this answer
 
VB
'   Quick routine to convert from DataGridViewTriState to boolean.
'   True goes to true while False and NotSet go to false.
Protected Shared Function BoolFromTri(tri As DataGridViewTriState) As Boolean
    Return If((tri = DataGridViewTriState.[True]), True, False)
End Function



'  Routine to convert from boolean to DataGridViewTriState.
Private Shared Function TriBool(value As Boolean) As DataGridViewTriState
    Return If(value, DataGridViewTriState.[True], DataGridViewTriState.[False])
End Function




http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
 
Share this answer
 
 
Share this answer
 
Comments
sunandandutt 17-May-12 5:08am    
very good link thanxz arun

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900