-
Aug 3rd, 2002, 02:06 PM
#1
Thread Starter
yay gay
What is the vbUnicode equivalent in .NET?
what is it? i am needing for this API:
VB Code:
Private Declare Function DoFileDownload Lib "shdocvw" _
(ByVal lpszFile As String) As Long
Private Sub dnload()
Dim sDownload As String
sDownload = StrConv(Text1.Text, [b]vbUnicode[/b])
Call DoFileDownload(sDownload)
End Sub
anyone could help me converting this to .NET code..?
-
Aug 3rd, 2002, 02:33 PM
#2
Lively Member
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
-
Aug 3rd, 2002, 02:34 PM
#3
Thread Starter
yay gay
tks all check it, i saw msdn and there is no unicode in .NET
-
Aug 3rd, 2002, 02:36 PM
#4
Thread Starter
yay gay
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'.
-
Aug 3rd, 2002, 02:50 PM
#5
Lively Member
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.
-
Aug 3rd, 2002, 02:52 PM
#6
Thread Starter
yay gay
-
Aug 3rd, 2002, 02:54 PM
#7
Thread Starter
yay gay
-
Aug 3rd, 2002, 05:32 PM
#8
Hyperactive Member
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.
-
Aug 3rd, 2002, 07:09 PM
#9
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|