Reputation: 39
How can I fix this error?
I have imported System.IO.File
error: expression does not produce a value
Imports System.IO.File
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox9.Clear()
If CheckBox1.Checked = True Then
TextBox3.Text = "something"
End If
If CheckBox2.Checked = True Then
TextBox3.Text = textbox3.text + "other things.."
End If
If CheckBox2.Checked = True Then
TextBox3.Text = replace(textbox3.text, "a", "b")
End If
write = System.IO.File.AppendText("myfilepath")
write.WriteLine(TextBox3.Text)
write.Close()
End Sub
This line gets an error:
TextBox3.Text = replace(textbox3.text, "a", "b")
error:
Expression does not produce a value.
Upvotes: 0
Views: 3238
Reputation: 5520
Try to change the line of code like this:
TextBox3.Text = Strings.Replace(textbox3.text, "a", "b")
Or like this:
TextBox3.Text = TextBox3.Text.Replace("a", "b")
In Visual Studio when you go hover with mouse, you can get some information, as the Namespace of the function/class etc... check it too.
Updated with explanation
The import of System.IO.File
brings with it a method that does not produce results, so forcing the full name of the namespace (Strings.replace(...)
), the issue is resolved, and there is no more conflict between the methods with the same name.
The MS guide for the method in namespace System.IO.File
Upvotes: 4