• DİKKAT

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

Block if without end if hatası

Katılım
15 Mayıs 2014
Mesajlar
6
Excel Vers. ve Dili
2013 türkçe
textboxlardan herhangi biri boş geçildiğinde uyarı vermesini istiyorum. textboxlara value yazılmalı, text değil, ancak burdaki sorun ne?

Kod:
Private Sub CommandButton1_Click()

Dim kütle1 As Double, kütle2 As Double, uzaklık As Double, F As Double

kütle1 = TextBox1.Value
kütle2 = TextBox2.Value
uzaklık = TextBox3.Value
G = 6.67

If kütle1 = "" Then
    MsgBox ("Lütfen Birinci Kütle Değerini Giriniz")
If kütle2 = "" Then
    MsgBox ("Lütfen İkinci Kütle Değerini Giriniz")
If uzaklık = "" Then
    MsgBox ("Lütfen Kütleler Arası Uzaklık Değerini Giriniz")
Else
    F = G * kütle1 * kütle2 / uzaklık * uzaklık
    TextBox4.Text = F
    MsgBox ("Sonucun Sonuna x10 üzeri -11 Ekleyiniz")
End If

kütle1 = Empty
kütle2 = Empty
uzaklık = Empty

End Sub
 
İlk If komutundan sonra takip eden diğer iki If in başına Else getirirseniz hata vermez. İlk başlayan If, diğerleri ElseIf olmalı.
Kolay gelsin.
 
End If
3 adet yazarsanız sanırım hata almazsınız.

End If
End If
End If
 
denedim ancak bu sefer de Type mismatch hatası verdi. uyumsuzluk içinse "kütle1 = TextBox1.Value" gösteriyor
 
Kodlarınıza Exit Sub ekleyiniz.

If kütle1 = "" Then
MsgBox ("Lütfen Birinci Kütle Değerini Giriniz")
Exit Sub
If kütle2 = "" Then
MsgBox ("Lütfen İkinci Kütle Değerini Giriniz")
Exit Sub
If uzaklık = "" Then
MsgBox ("Lütfen Kütleler Arası Uzaklık Değerini Giriniz")
Exit Sub
Else
F = G * kütle1 * kütle2 / uzaklık * uzaklık
TextBox4.Text = F
MsgBox ("Sonucun Sonuna x10 üzeri -11 Ekleyiniz")
End If
End If
End If
 
Son düzenleme:
Deneyin...

Kod:
Private Sub CommandButton1_Click()

    Dim kütle1 As Double, kütle2 As Double, uzaklık As Double, F As Double
    
    kütle1 = TextBox1.Value
    kütle2 = TextBox2.Value
    uzaklık = TextBox3.Value
    G = 6.67
    
    If kütle1 = "" Then
        MsgBox ("Lütfen Birinci Kütle Değerini Giriniz")
       [B] If kütle2 = "" Then MsgBox ("Lütfen İkinci Kütle Değerini Giriniz")
        If uzaklık = "" Then MsgBox ("Lütfen Kütleler Arası Uzaklık Değerini Giriniz")
        Exit Sub[/B]
    Else
        F = G * kütle1 * kütle2 / uzaklık * uzaklık
        TextBox4.Text = F
        MsgBox ("Sonucun Sonuna x10 üzeri -11 Ekleyiniz")
    End If
    
    kütle1 = Empty
    kütle2 = Empty
    uzaklık = Empty

End Sub
 
Hiçbiri işe yaramadı, sorun hala devam ediyor. Sabahtan beri bununla uğraşıyorum, kafayı yicem.
 
Şu Kodu denermisiniz.

Kod:
Private Sub CommandButton1_Click()

G = 6.67

    If TextBox1.Text = Empty Then
    MsgBox "TextBox1 Boş Görünüyor", vbExclamation, "Mustafa MUTLU 0 533 740 45 49"
    Exit Sub
    End If
    If TextBox2.Text = Empty Then
    MsgBox "TextBox2 Boş Görünüyor", vbExclamation, "Mustafa MUTLU 0 533 740 45 49"
    Exit Sub
    End If
    If TextBox3.Text = Empty Then
    MsgBox "TextBox3 Boş Görünüyor", vbExclamation, "Mustafa MUTLU 0 533 740 45 49"
    Exit Sub
    End If

TextBox4.Value = (G * (Val(TextBox1) * Val(TextBox2)))/ (Val(TextBox3) * Val(TextBox3))

    MsgBox ("Sonucun Sonuna x10 üzeri -11 Ekleyiniz")


End Sub
 
Son düzenleme:
mustafa bey, bu sefer oldu, teşekkür ederim.

bir şey merak ediyorum. siz de farketmişsinizdir, 10 üzeri -11 diye mesaj kutusu oluşturdum. acaba sonuca kendisi böyle bir ifade yazabilir mi?
 
Nasıl yani
Bir örnekle açıklarmısınız.
 
7m6q8P

bunun gibi
 
Hücreye
=10^34
Yazdığınızda sonucu görürsünüz.

Örneğin :
MsgBox ("Sonucun Sonuna x10 üzeri -11 Ekleyiniz")
Kodu silip aşağıdaki kodu ekleyin MsgBox ta sonucu görün.

[A1] = "=10^34"
Mutlu = TextBox4.Value * [A1]
MsgBox Mutlu
[A1]=""
 
Merhaba
Yukarıdaki gibi sorunla uğraşıyorum sonuç alamadım.Hata nedir?

Private Sub CommandButton5_Click()

Dim tarih1 As Date, tarih2 As Date: Dim ara As Range, satir As Integer
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Worksheets("VERİ"): Set s2 = Worksheets("RPR")
tarih1 = Format(TextBox2.Value, "dd.mm.yyyy")

satir = 2: s2.Cells.ClearContents

For Each ara In s1.Range("b2:b" & Range("b65536").End(3).Row)
If CLng(CDate(ara.Value)) >= CLng(CDate(tarih1)) And _
CLng(CDate(ara.Value)) <= CLng(CDate(tarih1)) And _
CStr(ara.Offset(0, 1).Value) = CStr(TextBox2.Text) Then
Exit Sub
Dim sat, son As Integer
For sat = 2 To Cells(65536, "B").End(xlUp).Row
If Cells(sat, "B") = TextBox2 Then
MsgBox "GİRMİŞ OLDUĞUNUZ HESAP KAYITLARDA BULUNMAKTADIR", vbInformation

Exit Sub: End If: Next
If TextBox2.Value <> "" Then
Exit Sub

Son_Dolu_Satir = Sheets("VERİ").Range("A65536").End(xlUp).Row
Bos_Satir = Son_Dolu_Satir + 1
Sheets("VERİ").Range("A" & Bos_Satir).Value = _
Application.WorksheetFunction.Max(Sheets("VERİ").Range("A:A")) + 1
'TextBox1.Value = Sheets("VERİ").Range("a65536").End(xlUp).Value + 1
'Sheets("VERİ").Range("A" & Bos_Satir).Value = TextBox1.Value
Sheets("VERİ").Range("C" & Bos_Satir).Value = ComboBox1.Value
Sheets("VERİ").Range("D" & Bos_Satir).Value = TextBox3.Text
Sheets("VERİ").Range("E" & Bos_Satir).Value = ComboBox2.Text
Sheets("VERİ").Range("F" & Bos_Satir).Value = TextBox4.Text
Sheets("VERİ").Range("B" & Bos_Satir).Value = TextBox2.Text
Sheets("VERİ").Range("G" & Bos_Satir).Value = ComboBox3.Text
Sheets("VERİ").Range("H" & Bos_Satir).Value = TextBox5.Text
Sheets("VERİ").Range("I" & Bos_Satir).Value = TextBox6.Text
Sheets("VERİ").Range("J" & Bos_Satir).Value = TextBox7.Text
Sheets("VERİ").Range("M" & Bos_Satir).Value = TextBox10.Text
Sheets("VERİ").Range("K" & Bos_Satir).Value = TextBox8.Text
Sheets("VERİ").Range("L" & Bos_Satir).Value = TextBox9.Text
Sheets("VERİ").Range("N" & Bos_Satir).Value = TextBox11.Text
Sheets("VERİ").Range("O" & Bos_Satir).Value = TextBox12.Text
Sheets("VERİ").Select
Sheets("RPR").Range("A" & Bos_Satir).Value = _
Application.WorksheetFunction.Max(Sheets("RPR").Range("A:A")) + 1
Sheets("RPR").Range("B" & Bos_Satir).Value = TextBox2.Text
Sheets("RPR").Range("C" & Bos_Satir).Value = ComboBox1.Value
Sheets("RPR").Select
Else
MsgBox " LÜTFEN ! HESAP ADI GİRİNİZ"
End If

TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
End If
Exit Sub
End Sub
 
Geri
Üst