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 4618642
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:46+00:00 2026-05-22T02:17:46+00:00

I have this function: Function WriteTextToFile(ByVal data) Dim file As New System.IO.StreamWriter(E:\storage.txt) file.WriteLine(data) file.Close()

  • 0

I have this function:

Function WriteTextToFile(ByVal data)
    Dim file As New System.IO.StreamWriter("E:\storage.txt")
    file.WriteLine(data)
    file.Close()
End Function

I have been trying to adjust it so that the filepath becomes a variable I can pass to allow for multiple storage files. Something like this:

Function AppendTextToFile(ByVal data, ByVal path)

        Dim file As New System.IO.StreamWriter(path, True)
        file.WriteLine(data)
        file.Close()

    End Function

However while function 1 works, function 2 doesn’t – I get this unhelpful error:

Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:
    'Public Sub New(path As String)': Argument matching parameter 'path' narrows from 'Object' to 'String'.
    'Public Sub New(stream As System.IO.Stream)': Argument matching parameter 'stream' narrows from 'Object' to 'System.IO.Stream'. C:\Users\films ratings\films ratings\Form1.vb

I normally work in PHP and I’ve never seen an error of this nature before. What does it mean and can I re-write the function to get what I want?

  • 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-22T02:17:46+00:00Added an answer on May 22, 2026 at 2:17 am

    Declare the variable path as a String type and you’ll be fine.

    The compiler is not able to determine what overload of the constructor should be used because you declared the path parameter as Object (that’s the default when you don’t specify otherwise).

    Instead, you should declare your second function like this:

    Function AppendTextToFile(ByVal data, ByVal path As String)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function... private string dateConvert(string datDate) { System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo(en-GB);
I have this function that loads an specific .log file: function loadTracks():void { tracksLoader.load(new
I have this function to read in all ints from the file. The problem
I have this function that returns a DataTable : Public Shared Function GetDataTable(ByVal PageSize
I have this function in javascript file which works perfectly fine in Firefox /
I have this function stored in db.system.js function SomeFunc(o) { x = db.Collection; while(
I have this function: void myFunc(NSString* data) { NSMutableArray *instrs = [[NSMutableArray alloc] initWithCapacity:[data
I have this function in my Javascript Code that updates html fields with their
I have this function in my head: <head> window.onload = function(){ var x =
I have this function from a plugin (from a previous post) // This method

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.