in this post you can learned how to make sample calculator in vb.net just copy the code then apply
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
TextBox3.Text = TextBox1.Text & " + " & TextBox2.Text & " = " & TextBox3.Text
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
TextBox3.Text = TextBox1.Text & " - " & TextBox2.Text & " = " & TextBox3.Text
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
TextBox3.Text = TextBox1.Text & " x " & TextBox2.Text & " = " & TextBox3.Text
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
TextBox3.Text = TextBox1.Text & " / " & TextBox2.Text & " = " & TextBox3.Text
End Sub
End Class
Imports System.IO
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Save File In .txt (Notepad)
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Text [*.txt*]|*.txt"
Save.CheckPathExists = True
Save.Title = "Save File"
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(Save.FileName)
myStreamWriter.Write(TextBox1.Text)
myStreamWriter.Flush()
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
System.IO.File.WriteAllText(SaveFileDialog1.FileName, TextBox1.Text)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SaveFileDialog1.Filter = "Word Documents|*.doc"
End Sub
End Class
Post a Comment