So I have problem with a code I am writing, when I write a string to a text document, I get the following error; "Conversion from string "1, 1, 2, 3, 5, 8, 13, 21, 34, 55" to type 'Integer' is not valid." Please help; code below. Thanks in advance!
Imports System.IO
Imports System.Numerics
Public Class Form1
Dim path As String
Dim clicked As Boolean
Dim pastfib2 As BigInteger
Dim pastfib As BigInteger
Dim fib As BigInteger
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "1, 1, "
pastfib = 1
pastfib2 = 1
Timer1.Enabled = True
clicked = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
fib = pastfib + pastfib2
TextBox1.Text = TextBox1.Text & fib.ToString & ", "
pastfib2 = pastfib
pastfib = fib
TextBox1.SelectionStart = TextBox1.TextLength
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True And clicked = True Then
Timer1.Enabled = False
Else
Timer1.Enabled = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
clicked = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myStream As Stream = Nothing
Dim saveFileDialog1 As New SaveFileDialog()
Dim text As String
Text = TextBox1.Text
saveFileDialog1.InitialDirectory = Apppath()
saveFileDialog1.Filter = "text files (*.txt)|*.txt"
SaveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = saveFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
Dim ioFile As New StreamReader(myStream)
Write(text) <---------------------------ERROR HERE
ioFile.Close()
myStream.Close()
End If
End If
End Sub
Public Function Apppath() As String
Return System.AppDomain.CurrentDomain.BaseDirectory()
End Function
End Class