• DİKKAT

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

Textboxta Islem Yapma

Selamlar,

Sn. abtani ekteki örnek dosyayı incelermisiniz.
 
Teşekkürler,süpersiniz.Sanırım + yerine -,* ,/ kullanarak dört işlemi hallebiliriz.
 
Selamlar,

Sn. pelin5353 ekte örnek dosyanız üzerinde gerekli düzenlemeleri yaptım. Formunuzda kullandığınız TextBox indexleri ardışık değildi tümünü silip ardışık olacak şekilde yeniden oluşturdum. Bu haliyle kodlamada biraz daha derli toplu oldu. Umarım faydası olur.
 
Son düzenleme:
Sayın Orion2; 14 nolu mesajdaki eklediğim dosyadaki hataya bakma şansınız olduğu.COST_CONTROL arkadaşımızdan öğrendiklerimizin yanına sizin eklediğiniz kodu da eklemek isterdim.
 
Selamlar,

Sn. abtani kodunuzu aşağıdaki şekilde değiştirip denermisiniz.

Kod:
Private Sub CommandButton1_Click()
    Dim sayi1, sayi4, sayi7, sayi10, sayi13, sayi16, sayi19, sayi22, sayi25, sayi28, sayi31, sayi34, sayi37, sayi40, sayi43, sayi46, sayi49, sayi52, sayi55, sayi58, sayi61, sayi64, sayi67, sayi70 As Long
    
    sayi1 = CDbl(TextBox1.Value)
    sayi4 = CDbl(TextBox4.Value)
    sayi7 = CDbl(TextBox7.Value)
    sayi10 = CDbl(TextBox10.Value)
    
    sayi13 = CDbl(TextBox13.Value)
    sayi16 = CDbl(TextBox16.Value)
    sayi19 = CDbl(TextBox19.Value)
    sayi22 = CDbl(TextBox22.Value)
    
    sayi25 = CDbl(TextBox25.Value)
    sayi28 = CDbl(TextBox28.Value)
    sayi31 = CDbl(TextBox31.Value)
    sayi34 = CDbl(TextBox34.Value)
    
    sayi37 = CDbl(TextBox37.Value)
    sayi40 = CDbl(TextBox40.Value)
    sayi43 = CDbl(TextBox43.Value)
    sayi46 = CDbl(TextBox46.Value)
    
    sayi49 = CDbl(TextBox49.Value)
    sayi52 = CDbl(TextBox52.Value)
    sayi55 = CDbl(TextBox55.Value)
    sayi58 = CDbl(TextBox58.Value)
    
    sayi61 = CDbl(TextBox61.Value)
    sayi64 = CDbl(TextBox64.Value)
    sayi67 = CDbl(TextBox67.Value)
    sayi70 = CDbl(TextBox70.Value)
    
    TextBox74.Value = Format(sayi1 + sayi4 + sayi7 + sayi10 + sayi13 + sayi16 + sayi19 + sayi22 + sayi25 + sayi28 + sayi31 + sayi34 + sayi37 + sayi40 + sayi43 + sayi46 + sayi49 + sayi52 + sayi55 + sayi58 + sayi61 + sayi64 + sayi67 + sayi70, "#,##0.00")
End Sub
 
Uyguladım,sorunsuz şekilde toplam aldı.Sanırım textboxların başına CDbl yazmak gerekiyormuş.Yeni bir şey daha öğrendik.(Her nekadar CDb1 ne demekse).Teşekkürler,saygılar
 
Selamlar,

Sn. abtani aşağıdaki ingilizce açıklamalar VBE yardım bölümünden alıntıdır.

Kod:
Type Conversion Functions
      

Each function coerces an expression to a specific data type.

Syntax

CBool(expression)

CByte(expression)

CCur(expression)

CDate(expression)

CDbl(expression)

CDec(expression)

CInt(expression)

CLng(expression)

CSng(expression)

CStr(expression)

CVar(expression)

The required expression argument is any string expression or numeric expression.

Return Types

The function name determines the return type as shown in the following:

Function Return Type Range for expression argument 
CBool Boolean Any valid string or numeric expression. 
CByte Byte  0 to 255. 
CCur Currency  -922,337,203,685,477.5808 to 922,337,203,685,477.5807. 
CDate Date  Any valid date expression. 
CDbl Double  -1.79769313486231E308 to 
-4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. 
CDec Decimal +/-79,228,162,514,264,337,593,543,950,335 for zero-scaled numbers, that is, numbers with no decimal places. For numbers with 28 decimal places, the range is 
+/-7.9228162514264337593543950335. The smallest possible non-zero number is 0.0000000000000000000000000001. 
CInt Integer -32,768 to 32,767; fractions are rounded. 
CLng Long -2,147,483,648 to 2,147,483,647; fractions are rounded. 
CSng Single -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values. 
CStr String Returns for CStr depend on the expression argument. 
CVar Variant Same range as Double for numerics. Same range as String for non-numerics. 



Remarks

If the expression passed to the function is outside the range of the data type being converted to, an error occurs.

In general, you can document your code using the data-type conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CCur to force currency arithmetic in cases where single-precision, double-precision, or integer arithmetic normally would occur.

You should use the data-type conversion functions instead of Val to provide internationally aware conversions from one data type to another. For example, when you use CCur, different decimal separators, different thousand separators, and various currency options are properly recognized depending on the locale setting of your computer.

When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2. CInt and CLng differ from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. Also, Fix and Int always return a value of the same type as is passed in.

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.

A CVDate function is also provided for compatibility with previous versions of Visual Basic. The syntax of the CVDate function is identical to the CDate function, however, CVDate returns a Variant whose subtype is Date instead of an actual Date type. Since there is now an intrinsic Date type, there is no further need for CVDate. The same effect can be achieved by converting an expression to a Date, and then assigning it to a Variant. This technique is consistent with the conversion of all other intrinsic types to their equivalent Variant subtypes.

Note   The CDec function does not return a discrete data type; instead, it always returns a Variant whose value has been converted to a Decimal subtype.
 
Uyguladım,sorunsuz şekilde toplam aldı.Sanırım textboxların başına CDbl yazmak gerekiyormuş.Yeni bir şey daha öğrendik.(Her nekadar CDb1 ne demekse).Teşekkürler,saygılar

CDbl = Double değişken tipi,hakkında aşağıdaki bilgiyi okuyunuz.:cool:
Double -1.79 x 10^308 ile 1.79 x 10^308 arasında değer alabilir. 8 byte yer kaplar. Değişken isminin sonuna # işareti konularak deklare edilebilir.
 
COST_CONTROL önce türkçesini anlamaya çalışalım,ingilizcesine sonra bakarız.
Sabrınız hayrayım,gerçi öğretmen olarak derste bende sabırlıyım ama,burada ben bile kendi kendime çok kızıyorum.
 
önce türkçesini anlamaya çalışalım,ingilizcesine sonra bakarız.
28 nolu mesaja baktınızmı?
 
Baktım tabi,anlamını kavrayabilmem için çok çalışmam lazım çok...
 
Bende kısa bir bilgi vereyim. Sn COST_CONTROL'un verdiği fonksiyonlar değişken tiplerini birbirine çevirmek amacıyla kullanılır.

Değişkenler hakkında detay bilgi için aşağıdaki linki incelemenizi öneririm.

DEĞİŞKENLER - VARIABLES
 
Sn. Cost Control ,

Gercekten cok emek vermissiniz.. Cok tesekkur ederim. Ellerinize sayglik
 
Dosyayi orjinaline uygun hale getirdim ancak bu defa anlam veremedigim bi sorun olustu..

1.si textbox 119 toplam alirken binler basamaginin olusmasina engel oluyor ve toplami 1.000 yerine 1,00 olarak algiliyor. Ama yuzler basamagina cikmada sorun yok yine.. Ki ayni format diger textboxlarda sorunsuz calisiyor.. :???:

2.si textbox104 ve105 bi turlu toplama dahil olmuyor. :???:
 
Selamlar,

Sn. pelin5353,

Class modülündeki aşağıdaki kodu bir sonraki ile değiştirip denermisiniz.

Eski hali;
Kod:
Private Sub Txt_Change()
    On Error Resume Next
    no = Replace(Txt.Name, "TextBox", "") + 1
    If no > 0 And no < 47 Then Call HESAPLA_1
    If no > 57 And no < 106 Then Call HESAPLA_2
End Sub

Yeni hali;
Kod:
Private Sub Txt_Change()
    On Error Resume Next
    no = Replace(Txt.Name, "TextBox", "") + 1
    If no > 0 And no < 47 Then Call HESAPLA_1
    If no > 57 And no < 120 Then Call HESAPLA_2
End Sub
 
Sn. Cost Control,

2. sorun giderildi ama 1. sorun hala devam ediyor.. Hala 119. textboxta toplamin 1000 ler basamagina cikmasina engel oluyor..Textbox formatini degistirdim. Bildigim butun formatlari denedim olmadi.
 
Selamlar,

Sn. pelin5353,

Class mod&#252;l&#252;ndeki "HESAPLA_1" isimli kodu a&#351;a&#287;&#305;daki ile de&#287;i&#351;tirip denermisiniz.

Kod:
Sub HESAPLA_1()
    For x = 1 To 46
    If UserForm1.Controls("TextBox" & x) = "" Then UserForm1.Controls("TextBox" & x) = Format(0, "#,##0.00")
    Next
    
    UserForm1.TextBox48 = Format(CDbl(UserForm1.TextBox1), "#,##0")
    UserForm1.TextBox49 = Format(CDbl(UserForm1.TextBox3) + CDbl(UserForm1.TextBox5) + CDbl(UserForm1.TextBox7) + CDbl(UserForm1.TextBox9), "#,##0")
    UserForm1.TextBox50 = Format(CDbl(UserForm1.TextBox11) + CDbl(UserForm1.TextBox13), "#,##0")
    UserForm1.TextBox51 = Format(CDbl(UserForm1.TextBox15), "#,##0")
    UserForm1.TextBox52 = Format(CDbl(UserForm1.TextBox17) + CDbl(UserForm1.TextBox19) + CDbl(UserForm1.TextBox21) + CDbl(UserForm1.TextBox23) + CDbl(UserForm1.TextBox25) + CDbl(UserForm1.TextBox27), "#,##0")
    UserForm1.TextBox53 = Format(CDbl(UserForm1.TextBox29) + CDbl(UserForm1.TextBox31) + CDbl(UserForm1.TextBox33), "#,##0")
    UserForm1.TextBox54 = Format(CDbl(UserForm1.TextBox35) + CDbl(UserForm1.TextBox37) + CDbl(UserForm1.TextBox39) + CDbl(UserForm1.TextBox41), "#,##0")
    UserForm1.TextBox55 = Format(CDbl(UserForm1.TextBox43), "#,##0")
    UserForm1.TextBox56 = Format(CDbl(UserForm1.TextBox45), "#,##0")
    
    UserForm1.TextBox110 = Format(CDbl(UserForm1.TextBox2), "#,##0.00 YTL")
    UserForm1.TextBox111 = Format(CDbl(UserForm1.TextBox4) + CDbl(UserForm1.TextBox6) + CDbl(UserForm1.TextBox8) + CDbl(UserForm1.TextBox10), "#,##0.00 YTL ")
    UserForm1.TextBox112 = Format(CDbl(UserForm1.TextBox12) + CDbl(UserForm1.TextBox14), "#,##0.00 YTL")
    UserForm1.TextBox113 = Format(CDbl(UserForm1.TextBox16), "#,##0.00 YTL")
    UserForm1.TextBox114 = Format(CDbl(UserForm1.TextBox18) + CDbl(UserForm1.TextBox20) + CDbl(UserForm1.TextBox22) + CDbl(UserForm1.TextBox24) + CDbl(UserForm1.TextBox26) + CDbl(UserForm1.TextBox28), "#,##0.00 YTL ")
    UserForm1.TextBox115 = Format(CDbl(UserForm1.TextBox30) + CDbl(UserForm1.TextBox32) + CDbl(UserForm1.TextBox34), "#,##0.00 YTL ")
    UserForm1.TextBox116 = Format(CDbl(UserForm1.TextBox36) + CDbl(UserForm1.TextBox38) + CDbl(UserForm1.TextBox40) + CDbl(UserForm1.TextBox42), "#,##0.00 YTL ")
    UserForm1.TextBox117 = Format(CDbl(UserForm1.TextBox44), "#,##0.00 YTL")
    UserForm1.TextBox118 = Format(CDbl(UserForm1.TextBox46), "#,##0.00 YTL")
    UserForm1.TextBox119 = Format(CDbl(UserForm1.TextBox110) + CDbl(UserForm1.TextBox111) + CDbl(UserForm1.TextBox112) + CDbl(UserForm1.TextBox113) + CDbl(UserForm1.TextBox114) + CDbl(UserForm1.TextBox115) + CDbl(UserForm1.TextBox116) + CDbl(UserForm1.TextBox117) + CDbl(UserForm1.TextBox118), "#,##0.00 YTL")
        
    For x = 48 To 56
    De&#287;er = UserForm1.Controls("TextBox" & x)
    If De&#287;er = "" Or IsNumeric(De&#287;er) Then Toplam = CDbl(De&#287;er) + Toplam
    Next
    If UserForm1.TextBox47 <> "" And UserForm1.TextBox47 > 0 Then
    UserForm1.TextBox57 = Format(Toplam, "#,##0")
    Else
    UserForm1.TextBox57 = Format(0, "#,##0")
    End If
End Sub
 
Sn. Cost Control,

Bu kodlarin neresinde hata var anlamiyorum. simdi de toplam almiyor.. Dosyayi ekliyorum.. Hatanin nerede oldugunu soyleyebilirseniz cok sevinirim.. Tesekkurler..
 
Selamlar,

Ekledi&#287;iniz dosyay&#305; indirip denedim ve sonu&#231; olumlu. Yani hesaplamalar&#305; gayet g&#252;zel yap&#305;yor.
 
Geri
Üst