- Katılım
- 12 Ekim 2023
- Mesajlar
- 7
- Excel Vers. ve Dili
- 2013 Türkçe
Kod:
Option Explicit
Private Sub CommandButton1_Click()
If Me.TextBox1 < 1900 Then Exit Sub
Me.TextBox1 = Me.TextBox1 - 1
Call olustur
End Sub
Private Sub CommandButton2_Click()
If Me.TextBox1 < 2100 Then Exit Sub
Me.TextBox1 = Me.TextBox1 + 1
Call olustur
End Sub
Private Sub CommandButton3_Click()
Dim suan
suan = Me.TextBox4
If suan = 12 Then Exit Sub
suan = suan + 1
Me.TextBox2 = MonthName(suan)
Me.TextBox4 = suan
Call olustur
End Sub
Private Sub CommandButton4_Click()
Dim suan
suan = Me.TextBox4
If suan = 1 Then Exit Sub
suan = suan - 1
Me.TextBox2 = MonthName(suan)
Me.TextBox4 = suan
Call olustur
End Sub
Private Sub UserForm_Initialize()
'Dim tbox As MSForms.Control, tbsay As Long
'With Me
'For Each tbox In .Control
'tbsay = tbsay + 1
'ReDim Preserve alltextbox(1 To tbsay)
'Set alltextbox(tbsay) = New clstextbox
'Set alltextbox(tbsay).tb = tbox
'End If
'Next
' End With
Me.TextBox4 = Month(Now)
Me.TextBox1 = Year(Now)
Me.TextBox2 = MonthName(Me.TextBox4)
Call olustur
End Sub
Sub olustur()
Dim i As Integer
For i = 1 To 42
dtp.Controls("t" & i).Value = ""
Next i
Dim bas_gun As String
Dim bas_tarih As Date
bas_gun = Format(DateSerial(dtp.TextBox1, dtp.TextBox4, 1), "dddd")
bas_tarih = CDate("01" & "." & dtp.TextBox4 & "." & dtp.TextBox1)
Dim aysonu As Date
Dim aysonu_gun As Date
aysonu = Format(Application.WorksheetFunction.EoMonth(bas_tarih, 0), "dd.mm.yyy")
aysonu_gun = Day(aysonu)
Select Case bas_gun
Case "Pazertesi"
dtp.t1 = 1
Case "Salı"
dtp.t2 = 1
Case "Çarşamba"
dtp.t3 = 1
Case "Perşembe"
dtp.t4 = 1
Case "Cuma"
dtp.t5 = 1
Case "Cumartesi"
dtp.t6 = 1
Case "Pazar"
dtp.t7 = 1
End Select
Dim c As MSForms.Controls
For Each c In dtp.Controls
Dim bul As String
If TypeName(c) = "Textbox" Then
If c.Text = "1" Then
bul = c.Name
End If
End If
Next
Dim ilk_kutu_no As Integer
Dim son_kutu_no As Integer
ilk_kutu_no = Right(bul, 1)
son_kutu_no = ilk_kutu_no + aysonu_gun
For i = ilk_kutu_no + 1 To son_kutu_no - 1
dtp.Controls("t" & i).Value = dtp.Controls("t" & i - 1).Value + 1
dtp.Controls("t" & i - 1).Visible = True
dtp.Controls("t" & i).Visible = True
Next i
For i = 1 To 42
If dtp.Controls("t" & i).Value = "" Then
dtp.Controls("t" & i).Visible = False
End If
Next i
End Sub
Almış olduğum hata ise
Run-time error 13
Type Mismatch
Kodlarda gözden kaçırdığım bir nokta mı var acaba ?
Çalışma Dosyası