Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4248404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:15:04+00:00 2026-05-21T04:15:04+00:00

I have the following Visual Basic 6.0 function which writes an ANSI string to

  • 0

I have the following Visual Basic 6.0 function which writes an ANSI string to a new file over FTP. I would like it to write the file as UTF-16LE. Is there any good way to do that within this following method?

Public Sub writeToFile(ByVal FTPServer As String _
                 , ByVal userName As String _
                 , ByVal password As String _
                 , ByVal contents As String _
                 , ByVal destinationFile As String)

    Dim hFile As Long
    Dim lCount As Long

    inetOpen
    inetConnect FTPServer, userName, password
    hFile = apiFtpOpenFile(m_hFTP, destinationFile, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0&)
    If hFile = 0 Then
        Err.Raise EWMFTPErrorCodes.wmFTPSendError, , internetError
    End If

    If apiInternetWriteFile(hFile, contents, Len(contents), lCount) = 0 Then
        Err.Raise EWMFTPErrorCodes.wmFTPSendError, , internetError
    End If

    apiInternetCloseHandle hFile
End Sub

I haven’t done Visual Basic 6.0 in about 10 years, so I’m shaky at best. Any input would be greatly appreciated.

Here is the apiInternetWriteFile declaration;

Private Declare Function apiInternetWriteFile Lib "wininet.dll" Alias "InternetWriteFile" ( _
                         ByVal hFile As Long _
                       , ByVal lpBuffer As String _
                       , ByVal dwNumberOfBytesToWrite As Long _
                       , ByRef lpdwNumberOfBytesWritten As Long) As Long
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:15:05+00:00Added an answer on May 21, 2026 at 4:15 am

    We need to see the declaration for apiInternetWriteFile. I’m pretty sure it’s a Declare into an API call, maybe something in WinINet.dll. My guess is that you need to:

    • Change the Declare so it expects a ByVal Long for the 2nd argument
    • EDIT to get a BOM at the start, try Contents = ChrW(&HFEFF&) & Contents. Or possibly FFEF, not sure of the endianness.
    • Pass StrPtr(contents) for the 2nd argument
    • Pass Len(contents)*2 for the 3rd argument (length in bytes)

    That will pass a Unicode UTF-16 string as the contents argument

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Visual Studio C++ 2008 I have the following code in my server.h file. #if
Hi I have a visual studio project which includes postbuildevents in the following form:
I am using Visual Basic 6 I have the following code structure: FUNCNINFO is
I'm fairly new to Visual Studio (specifically Visual Basic .NET) but have been programming
I am using visual basic 6. I have a button created which when pressed
In a Visual Basic 6.0 program, I have a string sTemp that I want
i have the following module and i would like to test connection. how do
I have the following configuration: Visual Studio Team System 2008 SQL Server Developer Edition
I have the following code behind a button in Visual Studio 2010 private void
I have the following array: a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] I use it for some visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.