[dba-VB] Convert C to VB

Eric Barro ebarro at verizon.net
Fri Jul 13 09:32:57 CDT 2007


Unfortunately most C# programmers don't even want to acknowledge VB.NET as
being equal in the programming world. Hence they don't even care to be
"ambidexterous" when it comes to programming in .NET.

VB.NET is much more forgiving and you can forego a lot of declarations that
C# will balk at and ask you to implicitly define in your code before you can
use it. I learned .NET using VB.NET and since then I have been using C#. 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Friday, July 13, 2007 5:38 AM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Convert C to VB

Yea, I was hoping that a member who uses C# might be able to translate this.
I am such a nubee that I am clueless.  I can translate syntax but not much
more.


John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Doris Manning
Sent: Friday, July 13, 2007 8:18 AM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Convert C to VB

You are right about the | character being an OR.  

A lot of times it boils down to looking up new things like "BindingFlags" in
the Object Browser and seeing what class/collection they are members of.  In
all the code I've ever seen that uses "BindingFlags", it always has
"System.Reflection." in front of it.

Doris Manning
Database Administrator
Hargrove Inc.

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Friday, July 13, 2007 8:00 AM
To: ebarro at verizon.net; dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Convert C to VB

Nope, still doesn't work.

VB complains about the | character.  I assume that is an OR so I replaced it
with the OR and then it complains about something else, specifically

        Dim t As System.Windows.Forms.FolderBrowserDialog = fbd.GetType

Saying that fdb.gettype cannot be coerced into a folderbrowserdialog

Which brings up a good point..

Why can't Visual Studio just pick the correct compiler for a class?  IOW
Visual Studio has all these compilers, why can't I just import an entire
class written in C# and expect Visual Studio to use the C# compiler to
compile and link that class as it would any other?  Seems a natural to me!

But alas...


John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Eric Barro
Sent: Friday, July 13, 2007 12:43 AM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Convert C to VB

Try this....

  Public Sub SetRootFolder(ByVal fbd As
System.Windows.Forms.FolderBrowserDialog, ByVal csidl As CsIdl)
        Dim t As System.Windows.Forms.FolderBrowserDialog = fbd.GetType
        dim fi as FieldInfo = t.GetField("rootFolder", BindingFlags.Instance
| BindingFlags.NonPublic)
        fi.SetValue(fbd, csidl)
    End Sub

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Thursday, July 12, 2007 9:33 PM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] Convert C to VB

I need to convert a chunk of 'C#' code to Vb.  The code apparently allows
you to get an expanded list of default values for the FolderBrowserDialog.

It isn't much and I (believe I) have mostly figured it out.

http://www.xoc.net/works/tips/folderbrowserdialog.asp

So far I have:

imports System;
imports System.Reflection;

Public Class FolderBrowserDialogEx
    '[Flags()]
    Public Enum CsIdl
        Desktop = &H0 ' Desktop
        Internet = &H1 ' Internet Explorer (icon on desktop)
        Programs = &H2 '// Start Menu\Programs
        Controls = &H3 ' My Computer\Control Panel
        Printers = &H4 ' My Computer\Printers
        Personal = &H5 ' My Documents
        Favorites = &H6 ' user name\Favorites
        Startup = &H7 ' Start Menu\Programs\Startup
        Recent = &H8 ' user name\Recent
        SendTo = &H9 ' user name\SendTo
        BitBucket = &HA ' desktop\Recycle Bin
        StartMenu = &HB ' user name\Start Menu
        MyDocuments = &HC ' logical "My Documents" desktop icon
        MyMusic = &HD ' "My Music" folder
        MyVideo = &HE ' "My Videos" folder
        DesktopDirectory = &H10 ' user name\Desktop
        Drives = &H11 ' My Computer
        Network = &H12 ' Network Neighborhood (My Network Places)
        Nethood = &H13 ' user name\nethood
        Fonts = &H14 ' windows\fonts
        Templates =                 &H0015,
        CommonStartMenu = &H16 ' All Users\Start Menu
        CommonPrograms = &H17 ' All Users\Start Menu\Programs
        CommonStartup = &H18 ' All Users\Startup
        CommonDesktopDirectory = &H19 ' All Users\Desktop
        AppData = &H1A ' user name\Application Data
        PrintHood = &H1B ' user name\PrintHood
        LocalAppData = &H1C ' user name\Local Settings\Applicaiton Data (non
roaming)
        AltStartup = &H1D ' non localized startup
        CommonAltStartup = &H1E ' non localized common startup
        CommonFavorites = &H1F
        InternetCache = &H20
        Cookies = &H21
        History = &H22
        CommonAppdata = &H23 ' All Users\Application Data
        Windows = &H24 ' GetWindowsDirectory()
        System = &H25 ' GetSystemDirectory()
        ProgramFiles = &H26 ' C:\Program Files
        MyPictures = &H27 ' C:\Program Files\My Pictures
        Profile = &H28 ' USERPROFILE
        SystemX86 = &H29 ' x86 system directory on RISC
        ProgramFilesX86 = &H2A ' x86 C:\Program Files on RISC
        ProgramFilesCommon = &H2B ' C:\Program Files\Common
        ProgramFilesCommonx86 = &H2C ' x86 Program Files\Common on RISC
        CommonTemplates = &H2D ' All Users\Templates
        CommonDocuments = &H2E ' All Users\Documents
        CommonAdminTools = &H2F ' All Users\Start
Menu\Programs\Administrative Tools
        AdminTools = &H30 ' user name\Start Menu\Programs\Administrative
Tools
        Connections = &H31 ' Network and Dial-up Connections
        CommonMusic = &H35 ' All Users\My Music
        CommonPictures = &H36 ' All Users\My Pictures
        CommonVideo = &H37 ' All Users\My Video
        Resources = &H38 ' Resource Direcotry
        ResourcesLocalized = &H39 ' Localized Resource Direcotry
        CommonOemLinks = &H3A ' Links to All Users OEM specific apps
        CdBurnArea = &H3B ' USERPROFILE\Local Settings\Application
Data\Microsoft\CD Burning
        ComputersNearMe = &H3D ' Computers Near Me (computered from
Workgroup membership)
        FlagCreate = &H8000 ' combine with CSIDL_ value to force folder
creation in SHGetFolderPath()
        FlagDontVerify = &H4000 ' combine with CSIDL_ value to return an
unverified folder path
        FlagNoAlias = &H1000 ' combine with CSIDL_ value to insure non-alias
versions of the pidl
        FlagPerUserInit = &H800 ' combine with CSIDL_ value to indicate
per-user init (eg. upgrade)
        FlagMask = &HFF00 ' mask for all possible flag values

    End Enum

    Private Sub FolderBrowserDialogEx()
    End Sub


    Public Sub SetRootFolder(ByVal fbd As
System.Windows.Forms.FolderBrowserDialog, ByVal csidl As CsIdl)
        Dim t As System.Windows.Forms.FolderBrowserDialog = fbd.GetType
        dim fi as FieldInfo = t.GetField("rootFolder", BindingFlags.Instance
| BindingFlags.NonPublic);
        fi.SetValue(fbd, (System.Environment.SpecialFolder) csidl);
    End Sub
End Class

That last chunk - SetRootFolder - just isn't cooperating.  Any help much
appreciated.

TIA.

John W. Colby
Colby Consulting
www.ColbyConsulting.com 

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com





More information about the dba-VB mailing list