What is the vbUnicode equivalent in .NET?-VBForums
Results 1 to 9 of 9

Thread: What is the vbUnicode equivalent in .NET?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    What is the vbUnicode equivalent in .NET?

    what is it? i am needing for this API:

    VB Code:
    1. Private Declare Function DoFileDownload Lib "shdocvw" _
    2.     (ByVal lpszFile As String) As Long
    3.  
    4. Private Sub dnload()
    5.    
    6.    Dim sDownload As String
    7.    
    8.    sDownload = StrConv(Text1.Text, [b]vbUnicode[/b])
    9.    Call DoFileDownload(sDownload)
    10.    
    11. End Sub

    anyone could help me converting this to .NET code..?

  2. #2
    Lively Member Tygur's Avatar
    Join Date
    Jul 2002
    Posts
    108
    Well, here's what I came up with after messing with it. Notice that I changed the API declaration. I'm not sure if there's an easier way, but this does work:
    Code:
        Private Declare Function DoFileDownload Lib "shdocvw" _
        (ByVal lpszFile() As Int16) As Long
    
        Private Sub dnload()
            'You can change this to take from a textbox again if you want
            Dim sDownload As String = "http://www.yahoo.com"
    
            Dim A(sDownload.Length) As Int16
            Dim I As Integer
            For I = 0 To sDownload.Length - 1
                A(I) = AscW(sDownload.Chars(I))
            Next
            A(sDownload.Length) = 0
            DoFileDownload(A)
        End Sub

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    tks all check it, i saw msdn and there is no unicode in .NET

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i am geting this error:

    C:\Documents and Settings\JBRANCO\My Documents\Visual Studio Projects\dev4\main.vb(257): Value of type '1-dimensional array of Short' cannot be converted to 'String'.

  5. #5
    Lively Member Tygur's Avatar
    Join Date
    Jul 2002
    Posts
    108
    I told you I changed the api declaration. You're going to have to change it in your app, too.

    Judging from your error, it looks like you forgot to do that.

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah ya sorry i suck
    -_-

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    working =)

  8. #8
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    Originally posted by PT Exorcist
    tks all check it, i saw msdn and there is no unicode in .NET
    Go read up on the String class in the MSDN help.

    The ToCharArray method copies the characters in a string to a Unicode character array.

    EDIT:

    Oh, and you shouldn't use unmanaged code with .NET. It slows things down quite a bit. Rather than declaring your DoFileDownload procedure, you should use the System.Net.WebClient class.
    Last edited by Hu Flung Dung; Aug 3rd, 2002 at 05:39 PM.

  9. #9
    Lively Member Tygur's Avatar
    Join Date
    Jul 2002
    Posts
    108
    Originally posted by Hu Flung Dung
    Go read up on the String class in the MSDN help.

    The ToCharArray method copies the characters in a string to a Unicode character array.
    Actually, Strings in VB.NET are already in unicode. And the Char datatype always specifies a unicode character. The problem is that VB automatically converts strings and characters to ANSI before passing them into an API function. This means that using ToCharArray doesn't help at all.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.