textbox veya label kuruşlu toplama sorunu

Katılım
2 Ocak 2022
Mesajlar
47
Excel Vers. ve Dili
2016 Türkçe
Merhaba, listbox1 içerisinde toplanması istenen column da sayı kuruşlu olarak görülüyor. Ancak toplam alınan textbox4 veya label17 de kuruş hanesini toplamadan virgül öncesi sayıları topluyor. Ne yanlış bulamadım. İlgilenecek arkadaşlara teşekkür ederim. İlgili Kodlar:
Private Sub TextBox1_AfterUpdate()
'Dim urunf, tutar As Long
Dim urunf, tutar, topla4 As Double
On Error GoTo yok
TextBox1.SetFocus
bul = TextBox1
Range("a:a").Find(bul, lookat:=xlWhole).Select
barkod = ActiveCell
urun = ActiveCell.Offset(0, 1).Value
urunf = ActiveCell.Offset(0, 2).Value
adet = TextBox5
tutar = adet * urunf
TextBox3.Text = FormatNumber(tutar, 2) & " TL"
TextBox2.Text = barkod & " - " & urun
TextBox6.Text = FormatNumber(urunf, 2) & " TL"


TextBox1.SetFocus
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = barkod
ListBox1.List(ListBox1.ListCount - 1, 1) = urun
ListBox1.List(ListBox1.ListCount - 1, 2) = FormatNumber(urunf, 2)
ListBox1.List(ListBox1.ListCount - 1, 3) = adet
ListBox1.List(ListBox1.ListCount - 1, 4) = FormatNumber(tutar, 2)
topla4 = 0
For i = 0 To ListBox1.ListCount - 1
topla4 = CDbl(Val(ListBox1.List(i, 4))) + CDbl(Val(topla4))
topla5 = CDbl(Val(ListBox1.List(i, 3))) + CDbl(Val(topla5))
Next i

'TextBox4.Text = FormatNumber(topla4, 2) & " TL"
Label17.Caption = FormatNumber(topla4, 2)
Label14 = topla5
ListBox1.Selected(ListBox1.ListCount - 1) = True

TextBox1 = ""
TextBox3 = ""
TextBox6 = ""
TextBox5 = 1
TextBox2 = ""
TextBox1.SetFocus
Exit Sub
yok: MsgBox "Ürün Kayıtlı Değil."
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox5 = ""
TextBox6 = ""
TextBox1.SetFocus
End Sub
 

Muzaffer Ali

Destek Ekibi
Destek Ekibi
Katılım
5 Haziran 2006
Mesajlar
5,873
Excel Vers. ve Dili
2019 Türkçe
Merhaba.
Tek satırda değişken tanımlama yapıyorsanız sadece en sondakini yapmanız yeterli değil hepsini tanımlamalısınız.

Kod:
Dim urunf, tutar, topla4 As Double
Aşağıdaki gibi olmalı.
Kod:
Dim urunf as double, tutar as double, topla4 As Double
 
Katılım
2 Ocak 2022
Mesajlar
47
Excel Vers. ve Dili
2016 Türkçe
Muzaffer Bey merhaba, yazdığınız gibi denedim, ancak sonuç değişmedi. Listbox1 içindeki sütuna gelen rakamlar kuruşlu olarak görülüyor, toplam aldığım textboxta kuruş hanesi ,00 olarak görülüyor. virgül sonrasını toplamıyor.
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
41,591
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Merhaba,

CDbl(Val(topla4)) gibi renkle belirttiğim bölümleri silerek deneyiniz. Benzer şekilde yazılmış olan bütün bölümleri değiştirip deneyiniz.
 
Katılım
2 Ocak 2022
Mesajlar
47
Excel Vers. ve Dili
2016 Türkçe
Tekrar Merhaba,
çok teşekkür ederim. Şimdi sorun çözüldü. İyi akşamlar dilerim.
 
Üst