• DİKKAT

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

Select Case Döngüsü

ahmed_ummu

Altın Üye
Katılım
28 Mart 2011
Mesajlar
777
Excel Vers. ve Dili
Excel 2010 Professional Plus 64 Bit
Merhaba arkadaşlar

Aşağıdaki kodu nasıl kısaltabilirim. 58 den 125'a kadar olacak. Tek tek yazarsam çok uzun ve saçma bir kod olacak. ... üç noktalı satırlar 65 ile 124 satırları temsil ediyor.
For Next ile denedim olmadı.
case is 57>< 126 denedim yine olmadı.

Yardımcı olursanız sevinirim.


Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Is = 58
Case Is = 59
Case Is = 60
Case Is = 61
Case Is = 62
Case Is = 63
Case Is = 64
Case Is = ...
Case Is = ...
Case Is = ...
Case Is = 125
KeyAscii = 0
End Select
End Sub
 
Aşağıdaki şekilde çözüldü. Textbox a 0,1,2,3,4,5,6,7,8,9 dan başka hiçbir karakter yazmaması için.

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
For i = 58 To 125
If KeyAscii = i Then
KeyAscii = 0
Else
End If
Next

For i = 33 To 47
If KeyAscii = i Then
KeyAscii = 0
Else
End If
Next
End Sub
 
Kod:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
        If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
 
Geri
Üst