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
        Me.Close()
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    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
                My.Computer.FileSystem.DeleteFile("c:\Users\Ollie\Desktop\test.txt")
                file = My.Computer.FileSystem.OpenTextFileWriter("c:\Users\Ollie\Desktop\test.txt", False)
                file.WriteLine("Bananas:" + NumericUpDown1.Value)
                file.WriteLine(NumericUpDown2.Value)
                file.WriteLine(NumericUpDown3.Value)
                file.Close()
            End If
        Else
            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

-

Solved

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

yeah only use + when adding number, use & when combining strings

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.