Hey need some quick help, some strange error I havent seen before even though ive been using the code for some time.

Imports System.IO
Public Class Form1

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim file As System.IO.StreamWriter
        Dim Overwrite As Integer
        If My.Computer.FileSystem.FileExists("c:\Users\Ollie\Desktop\test.txt") Then
            Overwrite = MessageBox.Show("Overwrite current config?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If Overwrite = 6 Then
                file = My.Computer.FileSystem.OpenTextFileWriter("c:\Users\Ollie\Desktop\test.txt", False)
                file.WriteLine("Bananas:" + NumericUpDown1.Value)
            End If
            MessageBox.Show("Config not saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End Sub
End Class

Error is with the

file.WriteLine("Bananas:" + NumericUpDown1.Value)

It doesnt seem to like them together, but it works fine without the bananas bit.

Im trying to get a text file that will say
Bananas: <number>

Any ideas please :D



file.WriteLine("Bananas:" & NumericUpDown1.Value)

Edited 5 Years Ago by BleepyE: n/a

This question has already been answered. Start a new discussion instead.