16 Ağustos 2014 Cumartesi
HESAP MAKİNASI PROJE ÖRNEĞİ
COMPUTEST Oto Ekspertiz Cihazları hakkında bilgi almak isterseniz
burayı
tıklayın
Hesap Makinası Kod Örneği
Skinli
5.12.2016
İNDİR
Hesap Makinası (Kod)
İNDİR
Imports System.Math Public Class Form1 #Region " FORM DEĞİŞKENLERİ.." Dim Sayi1, Sayi2, SayiX, xHafiza As Double Dim yOperatorTiklaninca, yKareKokTiklaninca, ySayiSilTiklaninca, bTamam, bQTamam As Boolean Dim sOperator, sGonderilenOperator, sGonderilenSayi As String 'operator=işlem işareti,"*,+,-,/ vb.." #End Region #Region " FORM TAŞIMA İŞLEMLERİ..." Const i As Integer = &HA1 Const j As Integer = 2 Private Sub Form1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then Me.Capture = False Dim msg As Message = Message.Create(Me.Handle, i, New IntPtr(j), IntPtr.Zero) Me.DefWndProc(msg) End If End Sub #End Region #Region " FORM OLAYLARI..(Load,Close,Keypress, KeyDown).. " Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ChkHepUstte.Checked = GetSetting("HM", "Ayarlar", "Hepüstte", True) LblHafizadakiSayi.Visible = False 'Memory btnHafizaYenile.Enabled = False 'Memory Restore LblGirilenSayi.Text = "0" txtFocus.Select() End Sub Private Sub KapatPic_Click(sender As System.Object, e As System.EventArgs) Handles KapatPic.Click SaveSetting("HM", "Ayarlar", "Hepüstte", Me.ChkHepUstte.Checked) Me.Close() End Sub Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed End End Sub Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _ Handles MyBase.KeyPress Dim Sayisal As Char Select Case e.KeyChar ' Sayısal Tuşlarla giriş Case Convert.ToChar(48) To Convert.ToChar(57) Sayisal = e.KeyChar bTamam = True Call GonSayilarin_islemSonucu(Sayisal) ' GERİAL, ve ONDALIK NOKTASI EŞİTTİR Case Convert.ToChar(8) GeriAl() Case ControlChars.CrLf sOperator = "Eşittir" Case Convert.ToChar(46) Call OndalikNokta() ' OPERATORLER Case Convert.ToChar(43) '+ Tıklandığında sGonderilenOperator = "+" Call OperatorSecimi() Case Convert.ToChar(45) '- Tıklandığında sGonderilenOperator = "-" Call OperatorSecimi() Case Convert.ToChar(42) '* Tıklandığında sGonderilenOperator = "*" Call OperatorSecimi() Case Convert.ToChar(47) '/ Tıklandığında sGonderilenOperator = "/" Call OperatorSecimi() ' OPERATÖRLERE AYRI YÜZDE ORANI TUT Case Convert.ToChar(37) ' % Tıklandığında Sayi2 = CDbl(LblGirilenSayi.Text) LblGirilenSayi.Text = (Sayi1 * Sayi2) / 100 LblKaydedilenSayi.Text = Sayi2 & "% de " & Sayi1 & " ifadesi" End Select txtFocus.Select() End Sub Private Sub Form1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If (e.KeyCode = Keys.Delete) Then btnTumSil.PerformClick() End If If (e.KeyCode = Keys.Back) Then btnTumSil.PerformClick() End If If (e.KeyCode = Keys.M) Then btnHafizaSil.PerformClick() End If End Sub #End Region #Region " BUTON OLAYLARI.." Private Sub LblHafizadakiSayi_Click(sender As System.Object, e As System.EventArgs) Handles LblHafizadakiSayi.Click btnHafizaYenile.PerformClick() End Sub Private Sub btnHafizaSil_Click(sender As Object, e As EventArgs) Handles btnHafizaSil.Click, btnHafizadanEksilt.Click, _ btnHafizayaEkle.Click, btnHafizaYenile.Click, btnHafizayaAl.Click Dim sGonder As String = sender.text Select Case sGonder Case "MC" xHafiza = 0 btnHafizaYenile.Enabled = False btnHafizayaAl.BackColor = SystemColors.ButtonFace LblHafizadakiSayi.Visible = False Case "M-" Try xHafiza = xHafiza - Val(LblGirilenSayi.Text) If xHafiza = 0 Then btnHafizaYenile.Enabled = False btnHafizayaAl.BackColor = SystemColors.GradientInactiveCaption LblHafizadakiSayi.Visible = False End If LblHafizadakiSayi.Text = "M " & "(" & xHafiza & ")" If LblHafizadakiSayi.Visible = False Or xHafiza < 0 Then btnHafizayaAl.BackColor = SystemColors.ButtonFace End If Catch ex As Exception MessageBox.Show(ex.Message, "Hata Oluştu", MessageBoxButtons.OK, _ MessageBoxIcon.Warning) End Try Case "M+" If xHafiza = 0 Then MessageBox.Show("Bellekte sayı Yok. Artırma işlemi Yapılamaz!", "Bellekte sayı Yok", MessageBoxButtons.OK, _ MessageBoxIcon.Information) Else xHafiza = xHafiza + Val(LblGirilenSayi.Text) If xHafiza = 0 Then btnHafizayaAl.BackColor = SystemColors.ButtonFace Else btnHafizayaAl.BackColor = SystemColors.GradientInactiveCaption End If LblHafizadakiSayi.Text = "M " & "(" & xHafiza & ")" End If Case "MR" LblGirilenSayi.Text = xHafiza Case "MS" xHafiza = Val(LblGirilenSayi.Text) If xHafiza = 0 Then MessageBox.Show("Hafızaya Alınacak Sayı Giriniz.", "Bellek Sıfır?", MessageBoxButtons.OK, MessageBoxIcon.Error) txtFocus.Select() Exit Sub End If btnHafizaYenile.Enabled = True LblHafizadakiSayi.Visible = True If xHafiza = 0 Then btnHafizayaAl.BackColor = SystemColors.ButtonFace Else btnHafizayaAl.BackColor = SystemColors.GradientInactiveCaption End If LblHafizadakiSayi.Text = "M " & "(" & xHafiza & ")" End Select txtFocus.Select() End Sub Private Sub btnGeriAl_Click(sender As Object, e As EventArgs) Handles btnGeriAl.Click Call GeriAl() txtFocus.Select() End Sub Private Sub GeriAl() Dim Uzunluk As Integer = Len(LblGirilenSayi.Text) If Len(Uzunluk) > 1 Then Uzunluk -= 1 LblGirilenSayi.Text = Mid(LblGirilenSayi.Text, 1, Uzunluk) Else If Len(LblGirilenSayi.Text) = 1 Then LblGirilenSayi.Text = "0" End If End If If LblGirilenSayi.Text = "" Then LblGirilenSayi.Text = "0" LblKaydedilenSayi.Text = "" bQTamam = False End If End Sub Private Sub TumunuSil() LblGirilenSayi.Text = "0" LblKaydedilenSayi.Text = "" Sayi1 = 0 Sayi2 = 0 SayiX = 0 sOperator = "" yOperatorTiklaninca = False yKareKokTiklaninca = False ySayiSilTiklaninca = False bQTamam = False End Sub Private Sub btnTumunuSil_Click(sender As Object, e As EventArgs) Handles btnTumSil.Click Call TumunuSil() LblGirilenSayi.ForeColor = Color.Black txtFocus.Select() End Sub Private Sub btnAlanSil_Click(sender As Object, e As EventArgs) Handles btnAlanSil.Click LblGirilenSayi.Text = "0" LblKaydedilenSayi.Text = "" bQTamam = False LblGirilenSayi.ForeColor = Color.Black txtFocus.Select() End Sub Private Sub btnNokta_Click(sender As Object, e As EventArgs) Handles btnNokta.Click Call OndalikNokta() txtFocus.Select() End Sub Private Sub btn0_Click(sender As Object, e As EventArgs) Handles btn0.Click, btn1.Click, btn2.Click, btn3.Click, _ btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click sGonderilenSayi = sender.text bTamam = True ' Tıklayarak Operatör anahtarları tekrar tekrar durdurmak için Call GonSayilarin_islemSonucu(sGonderilenSayi) txtFocus.Select() End Sub Private Sub OndalikNokta() If yOperatorTiklaninca = True Then LblGirilenSayi.Text = "" LblGirilenSayi.Text = "0." yOperatorTiklaninca = False End If If LblGirilenSayi.Text = "0" Then If InStr(LblGirilenSayi.Text, ".") Then Exit Sub Else LblGirilenSayi.Text = "0." End If End If If InStr(LblGirilenSayi.Text, ".") Then Exit Sub Else LblGirilenSayi.Text &= "." End If End Sub Private Sub btnArti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArti.Click, _ btnEksi.Click, btnCarp.Click, btnBol.Click sGonderilenOperator = sender.text Call OperatorSecimi() End Sub Private Sub GonSayilarin_islemSonucu(GonSayi As String) Try bQTamam = False If yOperatorTiklaninca = True Then LblGirilenSayi.Text = "" If LblGirilenSayi.Text = "0" Then LblGirilenSayi.Text = "" LblGirilenSayi.Text &= GonSayi yOperatorTiklaninca = False Catch ex As Exception MessageBox.Show(ex.Message, "Hata Oluştu..", MessageBoxButtons.OK, MessageBoxIcon.Warning) End Try End Sub Private Sub OperatorSecimi() Try bQTamam = False If bTamam = True Then ' Tekrar tekrar tuşlara dokunarak o sinir bozucu işlemi durdurmak için bTamam = False If LblGirilenSayi.Text.Length <> 0 Then If sOperator = "" Then Sayi1 = CDbl(LblGirilenSayi.Text) Else HesapToplami() End If yOperatorTiklaninca = True Select Case sGonderilenOperator Case "+" sOperator = "Ekle" LblKaydedilenSayi.Text = LblGirilenSayi.Text & "+" Case "-" sOperator = "Çıkar" LblKaydedilenSayi.Text = LblGirilenSayi.Text & "-" Case "*" sOperator = "Çarp" LblKaydedilenSayi.Text = LblGirilenSayi.Text & "*" Case "/" sOperator = "Böl" LblKaydedilenSayi.Text = LblGirilenSayi.Text & "/" End Select End If End If Catch ex As Exception MessageBox.Show(ex.Message, "Hata Oluştu..", MessageBoxButtons.OK, MessageBoxIcon.Warning) End Try End Sub Private Sub HesapToplami() Try Sayi2 = CDbl(LblGirilenSayi.Text) Select Case sOperator Case "Ekle" Sayi1 = Sayi1 + Sayi2 Case "Çıkar" Sayi1 = Sayi1 - Sayi2 Case "Böl" Sayi1 = Sayi1 / Sayi2 Case "Çarp" Sayi1 = Sayi1 * Sayi2 End Select LblGirilenSayi.Text = CStr(Sayi1) Catch ex As Exception MessageBox.Show(ex.Message, "Hata Oluştu..", MessageBoxButtons.OK, MessageBoxIcon.Warning) End Try End Sub Private Sub btnEsittir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEsittir.Click, btnYuzde.Click Try If bQTamam = True Then Exit Sub bQTamam = True Select Case sender.text Case "=" If LblGirilenSayi.Text.Length <> 0 AndAlso Sayi1 <> 0 Then HesapToplami() LblGirilenSayi.ForeColor = Color.Blue LblKaydedilenSayi.Text = "" End If Case "%" Sayi2 = CDbl(LblGirilenSayi.Text) If Sayi2 = 0 Then Exit Sub 'Girilen (sayi2) NOKTALI SAYI İSE (Sayi2 / 100) yap If InStr(LblGirilenSayi.Text, ".") Then Sayi2 = Sayi2 / 100 LblGirilenSayi.Text = (Sayi1 * Sayi2) / 100 LblKaydedilenSayi.Text = Sayi1 & "*" & Sayi2 & "/100=" & LblGirilenSayi.Text End Select sOperator = String.Empty Catch ex As Exception MessageBox.Show(ex.Message, "Hata Oluştu..", MessageBoxButtons.OK, MessageBoxIcon.Warning) End Try txtFocus.Select() End Sub Private Sub btn1BoluX_Click(sender As Object, e As EventArgs) Handles btn1BoluX.Click 'Bir sayısının herhangi bir sayıya bölümü Try If ySayiSilTiklaninca = True Then Call TumunuSil() Else Sayi1 = CDbl(LblGirilenSayi.Text) If Sayi1 = 0 Then LblKaydedilenSayi.Text = Sayi1 & " Sıfıra Bölünemez.." : Exit Sub LblGirilenSayi.Text = (1 / Sayi1) LblKaydedilenSayi.Text = 1 & "/" & Sayi1 & " = " ySayiSilTiklaninca = False End If Catch ex As Exception MessageBox.Show(ex.Message, "Hata oluştu", MessageBoxButtons.OK, MessageBoxIcon.Warning) End Try txtFocus.Select() End Sub Private Sub btnKareKoku_Click(sender As Object, e As EventArgs) Handles btnKareKoku.Click If yKareKokTiklaninca = True Then Call TumunuSil() Else Sayi1 = CDbl(LblGirilenSayi.Text) If Sayi1 = 0 Then Exit Sub LblGirilenSayi.Text = (Sqrt(Sayi1)) LblKaydedilenSayi.Text = "sqrt(" & (Sayi1) & ")" yKareKokTiklaninca = True End If txtFocus.Select() End Sub Private Sub txtFocus_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtFocus.KeyPress Form1_KeyPress(sender, e) End Sub Private Sub btnArtiEksi_Click(sender As Object, e As EventArgs) Handles btnArtiEksi.Click SayiX = CDbl(LblGirilenSayi.Text) If Not InStr(LblGirilenSayi.Text, "-") Then SayiX = (SayiX) * -1 LblGirilenSayi.Text = CStr(SayiX) Else SayiX = Abs(SayiX) LblGirilenSayi.Text = CStr(SayiX) End If txtFocus.Select() End Sub #End Region #Region " BUTON TOOLTIP OLAYLARI.." Private Sub btnHafizaSil_MouseHover(sender As System.Object, e As System.EventArgs) Handles btnHafizaSil.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(btnHafizaSil, "Hafızayı Sil - (Memory Clear)") End Sub Private Sub btnHafizaYenile_MouseHover(sender As System.Object, e As System.EventArgs) Handles btnHafizaYenile.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(btnHafizaYenile, "Hafızayı Göster - (Memory Restore) " & (xHafiza)) End Sub Private Sub btnHafizayaAl_MouseHover(sender As System.Object, e As System.EventArgs) Handles btnHafizayaAl.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(btnHafizayaAl, "Hafızaya Al - (Memory Send)") End Sub Private Sub btnHafizayaEkle_MouseHover(sender As System.Object, e As System.EventArgs) Handles btnHafizayaEkle.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(btnHafizayaEkle, "Hafızaya Ekle - (M+)") End Sub Private Sub btnHafizadanEksilt_MouseHover(sender As System.Object, e As System.EventArgs) Handles btnHafizadanEksilt.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(btnHafizadanEksilt, "Hafızadan Eksilt - (M-)") End Sub Private Sub LblHafizadakiSayi_MouseHover(sender As System.Object, e As System.EventArgs) Handles LblHafizadakiSayi.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(LblHafizadakiSayi, "Hafızayı Göster - (Memory Restore) " & (xHafiza)) End Sub #End Region #Region " KAPAT BUTONU ve MİNİMİZE OLAYLARI.." Private Sub KapatPic_MouseLeave(sender As System.Object, e As System.EventArgs) Handles KapatPic.MouseLeave KapatPic.Image = imList.Images("KapatHM.png") End Sub Private Sub KapatPic_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles KapatPic.MouseMove KapatPic.Image = imList.Images("KapatHM_R.png") End Sub Private Sub PicMinimize_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PicMinimize.MouseMove PicMinimize.Image = imList.Images("Minimize_R.png") End Sub Private Sub PicMinimize_MouseLeave(sender As System.Object, e As System.EventArgs) Handles PicMinimize.MouseLeave PicMinimize.Image = imList.Images("Minimize.png") End Sub #End Region #Region " FORM ÜSTTE ( Topmost ) OLAYI.." Private Sub ChkHepUstte_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles ChkHepUstte.CheckedChanged If Me.TopMost = True Then Me.TopMost = False ChkHepUstte.Text = "Üstte Değil" Else Me.TopMost = True ChkHepUstte.Text = "Hep Üstte" End If txtFocus.Select() End Sub Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PicMinimize.Click If Me.WindowState = FormWindowState.Normal Then Me.WindowState = FormWindowState.Minimized End If End Sub #End Region Private Sub LblGirilenSayi_MouseLeave(sender As System.Object, e As System.EventArgs) Handles LblGirilenSayi.MouseLeave Dim tooltip As New ToolTip() tooltip.SetToolTip(LblGirilenSayi, LblGirilenSayi.Text) End Sub End Class
Daha Yeni Kayıtlar
Önceki Kayıtlar
Ana Sayfa
Kaydol:
Kayıtlar (Atom)