• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

textbox toplam işlemi hata

Katılım
21 Ocak 2013
Mesajlar
425
Excel Vers. ve Dili
2010
Kod:
Private Sub CommandButton1_Click()
Dim t1 As Double
Dim t2 As Double
Dim t3 As Double
Dim t4 As Double
Dim t5 As Double
Dim t6 As Double
Dim t7 As Double
Dim t8 As Double
Dim t9 As Double
Dim t10 As Double
Dim t11 As Double
Dim t12 As Double
Dim t13 As Double
Dim t14 As Double


t1 = TextBox1.Value
t2 = TextBox2.Value
t3 = TextBox3.Value
t4 = TextBox4.Value
t5 = TextBox5.Value
t6 = TextBox6.Value
t7 = TextBox7.Value
t8 = TextBox8.Value
t9 = TextBox9.Value
t10 = TextBox10.Value
t11 = TextBox11.Value
t12 = TextBox12.Value
t13 = TextBox13.Value
t14 = TextBox14.Value


TextBox15 = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11 + t12 + t13 + t14
End Sub

Private Sub TextBox1_Change()
TextBox1 = Format(TextBox1, "###,0")
End Sub

Private Sub TextBox2_Change()
TextBox2 = Format(TextBox2, "###,0")
End Sub

Private Sub TextBox3_Change()
TextBox3 = Format(TextBox3, "###,0")
End Sub
Private Sub TextBox4_Change()
TextBox4 = Format(TextBox4, "###,0")
End Sub
Private Sub TextBox5_Change()
TextBox5 = Format(TextBox5, "###,0")
End Sub
Private Sub TextBox6_Change()
TextBox6 = Format(TextBox6, "###,0")
End Sub
Private Sub TextBox7_Change()
TextBox7 = Format(TextBox7, "###,0")
End Sub
Private Sub TextBox8_Change()
TextBox8 = Format(TextBox8, "###,0")
End Sub
Private Sub TextBox9_Change()
TextBox9 = Format(TextBox9, "###,0")
End Sub
Private Sub TextBox10_Change()
TextBox10 = Format(TextBox10, "###,0")
End Sub
Private Sub TextBox11_Change()
TextBox11 = Format(TextBox11, "###,0")
End Sub
Private Sub TextBox12_Change()
TextBox12 = Format(TextBox12, "###,0")
End Sub
Private Sub TextBox13_Change()
TextBox13 = Format(TextBox13, "###,0")
End Sub
Private Sub TextBox14_Change()
TextBox14 = Format(TextBox14, "###,0")
End Sub
Private Sub TextBox15_Change()
TextBox15 = Format(TextBox15, "###,0")
End Sub

textboxta toplama işlemi yapıyorum yalnız textbox boş olunca hata veriyor nasıl düzeltebilirim.
 
Merhaba,

Metin kutuları çoksa döngü kulullanılabilinir.

Kod:
Private Sub CommandButton1_Click()

    Dim Toplam As Double
   
    If Not TextBox1.Value = "" Then Toplam = Toplam + CDbl(TextBox1.Value)
    If Not TextBox2.Value = "" Then Toplam = Toplam + CDbl(TextBox2.Value)
    If Not TextBox3.Value = "" Then Toplam = Toplam + CDbl(TextBox3.Value)
    If Not TextBox4.Value = "" Then Toplam = Toplam + CDbl(TextBox4.Value)
   
    MsgBox Toplam

End Sub
 
Siz toplamı nerede görmek ya da kullanmak istiyorsanız orda Toplam değişkenini kullanabilirsiniz:

TextBox15 = Toplam

gibi.
 
TL simgesi derken ₺ simgesini kastediyorsanız textboxta bu simgeyi çıkaramadım. TL olarak isterseniz aşağıdaki gibi bir çözüm olabilir:

TextBox15 = Format(Toplam, "#,##0.00 TL")
 
₺ simgesini kastediyorsanız aşağıdaki gibi kullanabilrisiniz.
C++:
TextBox15 = FormatCurrency(Toplam)
 
Kod:
Private Sub textbox1_exit(ByVal cancel As MSForms.ReturnBoolean)
TextBox1.Text = Format(TextBox1.Text, "##,#0.00TL")

çözdüm kod bu şekilde oluyor.
 
Kod:
Private Sub CommandButton1_Click()
Dim Toplam As Double
  
    If Not TextBox1.Value = "" Then Toplam = Toplam + CDbl(TextBox1.Value)
    If Not TextBox2.Value = "" Then Toplam = Toplam + CDbl(TextBox2.Value)
    If Not TextBox3.Value = "" Then Toplam = Toplam + CDbl(TextBox3.Value)
    If Not TextBox4.Value = "" Then Toplam = Toplam + CDbl(TextBox4.Value)
    If Not TextBox5.Value = "" Then Toplam = Toplam + CDbl(TextBox5.Value)
    If Not TextBox6.Value = "" Then Toplam = Toplam + CDbl(TextBox6.Value)
    If Not TextBox7.Value = "" Then Toplam = Toplam + CDbl(TextBox7.Value)
    If Not TextBox8.Value = "" Then Toplam = Toplam + CDbl(TextBox8.Value)
    If Not TextBox9.Value = "" Then Toplam = Toplam + CDbl(TextBox9.Value)
    If Not TextBox10.Value = "" Then Toplam = Toplam + CDbl(TextBox10.Value)
    If Not TextBox11.Value = "" Then Toplam = Toplam + CDbl(TextBox11.Value)
    If Not TextBox12.Value = "" Then Toplam = Toplam + CDbl(TextBox12.Value)
    If Not TextBox13.Value = "" Then Toplam = Toplam + CDbl(TextBox13.Value)
    If Not TextBox14.Value = "" Then Toplam = Toplam + CDbl(TextBox14.Value)
    
    
   TextBox15 = Toplam

End Sub


Private Sub textbox1_exit(ByVal cancel As MSForms.ReturnBoolean)
TextBox1.Text = Format(TextBox1.Text, "##,#0.00TL")
End Sub

Private Sub textbox2_exit(ByVal cancel As MSForms.ReturnBoolean)
TextBox2.Text = Format(TextBox2.Text, "##,#0.00TL")
End Sub


bu şeklide toplama işlemi yapmıyor neden acaba
 
Merhaba,

Deneyiniz.
Kod:
Private Sub CommandButton1_Click()
    Dim i As Byte, topla As Double
    For i = 1 To 14
        If Controls("TextBox" & i) <> "" Then
            topla = topla + Replace(Controls("TextBox" & i), "TL", "")
        End If
    Next i
    TextBox15.Text = Format(topla, "##,#0.00TL")
End Sub
 
Kod:
Private Sub CommandButton1_Click()
    Dim i As Byte, topla As Double
    For i = 1 To 14
        If Controls("TextBox" & i) <> "" Then
            topla = topla + Replace(Controls("TextBox" & i), "TL", "")
        End If
    Next i
    TextBox15.Text = Format(topla, "##,#0.00TL")
End Sub


TL yerine toplamda ₺ cıkması gerekiyor düzenleyemedim.
 
bu kodda texboxlar boş olunca toplama işlemi yapmıyor hatayı düzeltemedim. yardımızı bekliyorum
 
Boşken ben herhangi bir hata almadım. Ayrıca formatını sizin #13. numaralı mesajdan kopyalamıştım.
Örnek dosya ekleyiniz.


.
 
Geri
Üst