CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    [RESOLVED] Help line of C# to VB.Net

    Could anyone here show me how to convert the code below to VB.Net
    Code:
     
          [DllImport("coredll.dll")]
          private static extern int SystemParametersInfo(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWiniIni);
    Thanks


    btw Using VS2005 but shouldn't make a difference
    Always use [code][/code] tags when posting code.

  2. #2
    Join Date
    Aug 2005
    Posts
    198

    Re: Help line of C# to VB.Net

    Code:
    <DllImport("coredll.dll")>
    Private Shared Function SystemParametersInfo(ByVal uiAction As UInteger, ByVal uiParam As UInteger, ByVal pvParam As StringBuilder, ByVal fWiniIni As UInteger) As Integer
    End Function
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Help line of C# to VB.Net

    hmm, Thanks.. I had that in there before but was having an issue, looks like the issue is elsewhere.

    I'm trying to detect when my app is running on a mobile device or in an emulator and found some code in C# to do this but my understanding of C# is not the greatest. I will keep working with it and see how it goes.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Help line of C# to VB.Net

    http://blogs.msdn.com/b/oldnewthing/.../10000406.aspx

    We would be able to help if you told us what the actual problem was/is.

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Help line of C# to VB.Net

    Looks like I found the problem. Turns out I had 2 issues. The first was I had not added the proper Imports statement to get the DLLImport to work hence my thinking there was an issue with the way the line was formatted.

    The other problem was I was creating an instance of the class and was getting a message that the line would not be evaluated. When I tried to reference the properties of said class. I can't remember the exact message now and I had tried a few different things since I posted.

    Anyway I just now tried to reproduce the error and got it to work instead. Still not sure why exactly, maybe related to the Namespace tags I added as well as making a direct call to the routine without creating a new instance of the class.

    Once I figure out exactly what the issue was I will post the results.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [RESOLVED] Help line of C# to VB.Net

    Apparently my probelms were

    1. I did not include the line
    Imports System.Runtime.InteropServices

    2. I was creating an instance of my class when what I actually needed was a reference to it instead.

    Seems to be working fine now.

    This is a big help for me as I write apps for handheld devices with barcode scanners and now can detect when they are being emulated so as to bypass the code which sets up the barcode scanner engine which would crash on the emulator. Now I shoudl be able to run on both the device and the emulator with no code changes.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured