Soru textboxdaki tarihe yıl ay gün ekleme

sirkülasyon

Altın Üye
Katılım
10 Temmuz 2012
Mesajlar
2,532
Excel Vers. ve Dili
2021 LTSC TR
Altın Üyelik Bitiş Tarihi
18-06-2026
İşlem yapılacak tarih = Textbox3
Yıl = Textbox4
Ay = Textbox5
Gün = Textbox6
Yeni Oluşacak Tarih = Textbox7

Textbox3' e
Herhangi bir süre (yıl, ay ya da gün) eklendiğinde yeni tarihin Textbox7 de oluşması için nasıl bir kod uygulayabilirim?
Saygılarımla
 

sirkülasyon

Altın Üye
Katılım
10 Temmuz 2012
Mesajlar
2,532
Excel Vers. ve Dili
2021 LTSC TR
Altın Üyelik Bitiş Tarihi
18-06-2026
Teşekkür Ederim
 

kemal turan

Altın Üye
Katılım
10 Haziran 2011
Mesajlar
1,676
Excel Vers. ve Dili
Excel 2010 32 bit
Altın Üyelik Bitiş Tarihi
06-10-2032
Merhaba sn Sirkülasyon,
Sorunuzun cevabı basit olabilir fakat isteğiniz pek anlaşılır değil.
"Textbox4, 5 ve 6 nın aşağıdaki sorunuzdaki rolü ve etkisi ne olacak ?
"Textbox3' e
Herhangi bir süre (yıl, ay ya da gün) eklendiğinde yeni tarihin Textbox7 de oluşması için nasıl bir kod uygulayabilirim? "

Yani olay sadece textbox3 ve textbox7 arasında geçmiyor.
Örnek bir dosya eklerseniz çözüm hızlı olur.
 

kemal turan

Altın Üye
Katılım
10 Haziran 2011
Mesajlar
1,676
Excel Vers. ve Dili
Excel 2010 32 bit
Altın Üyelik Bitiş Tarihi
06-10-2032
Merhaba Sn Sirkülasyon,
Bende sn. Nextlevel beyin önerisi ile araştırdım bulduğum kodu isteğinize uyarladım.
textbox 3 e tarih giriniz
textbox4 e eklemek istediğiniz yıl sayısını giriniz,
textbox5 e eklemek istediğiniz ay sayısını giriniz,
textbox6 e eklemek istediğiniz gün sayısını giriniz,
Kod:
Private Sub CommandButton7_Click()
Dim firstDate As Date, secondDate As Date, secondDate1 As Date, secondDate2 As Date, secondDate3 As Date
firstDate = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
secondDate1 = DateAdd("yyyy", TextBox4.Value, firstDate)
secondDate2 = DateAdd("m", TextBox5.Value, secondDate1)
secondDate3 = DateAdd("d", TextBox6.Value, secondDate2)
TextBox7 = Format(CDate(secondDate3), "dd.mm.yyyy")
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox3 = "" Then Exit Sub
TextBox3 = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
End Sub
commandbutton a tıklama ile textbox 7 de ulaşmak istediğiniz tarihi göreceksiniz.
veya
Sonucu en son girdiğiniz gün sayısı olan textbox6 change olayına bağlayabilirsiniz
Kod:
Private Sub TextBox6_Change()
Dim firstDate As Date, secondDate As Date, secondDate1 As Date, secondDate2 As Date, secondDate3 As Date
firstDate = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
secondDate1 = DateAdd("yyyy", TextBox4.Value, firstDate)
secondDate2 = DateAdd("m", TextBox5.Value, secondDate1)
secondDate3 = DateAdd("d", TextBox6.Value, secondDate2)
TextBox7 = Format(CDate(secondDate3), "dd.mm.yyyy")
End Sub
 
Son düzenleme:

kemal turan

Altın Üye
Katılım
10 Haziran 2011
Mesajlar
1,676
Excel Vers. ve Dili
Excel 2010 32 bit
Altın Üyelik Bitiş Tarihi
06-10-2032
Bu kodlar da exit olayı içindir.
Kod:
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox3 = "" Then Exit Sub
TextBox3 = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
End Sub

Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
Dim firstDate As Date, secondDate As Date, secondDate1 As Date, secondDate2 As Date, secondDate3 As Date
firstDate = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
secondDate1 = DateAdd("yyyy", TextBox4.Value, firstDate)
TextBox7 = Format(CDate(secondDate1), "dd.mm.yyyy")
End Sub
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
Dim firstDate As Date, secondDate As Date, secondDate1 As Date, secondDate2 As Date, secondDate3 As Date
firstDate = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
secondDate1 = DateAdd("yyyy", TextBox4.Value, firstDate)
secondDate2 = DateAdd("m", TextBox5.Value, secondDate1)
TextBox7 = Format(CDate(secondDate2), "dd.mm.yyyy")
End Sub

Private Sub TextBox6_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim firstDate As Date, secondDate As Date, secondDate1 As Date, secondDate2 As Date, secondDate3 As Date
firstDate = Format(CDate(TextBox3.Value), "dd.mm.yyyy")
secondDate1 = DateAdd("yyyy", TextBox4.Value, firstDate)
secondDate2 = DateAdd("m", TextBox5.Value, secondDate1)
secondDate3 = DateAdd("d", TextBox6.Value, secondDate2)
TextBox7 = Format(CDate(secondDate3), "dd.mm.yyyy")
End Sub
 

sirkülasyon

Altın Üye
Katılım
10 Temmuz 2012
Mesajlar
2,532
Excel Vers. ve Dili
2021 LTSC TR
Altın Üyelik Bitiş Tarihi
18-06-2026
Teşekkür ederim. Kemal abim
Ellerine sağlık. Sağ olasın
 

kemal turan

Altın Üye
Katılım
10 Haziran 2011
Mesajlar
1,676
Excel Vers. ve Dili
Excel 2010 32 bit
Altın Üyelik Bitiş Tarihi
06-10-2032
Rica ederim.
Selametle
 
Üst