Thema Datum  Von Nutzer Rating
Antwort
10.02.2011 09:59:15 Samse
NotSolved
10.02.2011 10:11:15 Severus
NotSolved
10.02.2011 10:28:58 Samse
NotSolved
10.02.2011 10:44:52 Severus
NotSolved
10.02.2011 10:47:54 Samse
NotSolved
10.02.2011 10:58:03 Severus
NotSolved
10.02.2011 11:08:48 Samse
NotSolved
10.02.2011 12:01:51 Severus
NotSolved
10.02.2011 12:40:19 Gast44226
NotSolved
10.02.2011 12:56:19 Severus
NotSolved
10.02.2011 13:01:39 Samse
NotSolved
10.02.2011 14:57:29 Severus
Solved
10.02.2011 15:55:45 Samse
NotSolved
11.02.2011 07:55:02 Severus
NotSolved
Rot Rot Keydown wie geht das?
01.03.2011 14:28:05 Samse
NotSolved

Ansicht des Beitrags:
Von:
Samse
Datum:
01.03.2011 14:28:05
Views:
899
Rating: Antwort:
  Ja
Thema:
Keydown wie geht das?

Hallo Severus

ich war einige Zeit nich an meiner Arbeit dran...

Jezt hab ich wieder angefangen und meinen Code umstrukturiert...:D

Jezt funzt das mit den Knöpfen nicht mehr :S 

Kanste mier weiterhelfen?

Hier der Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
Dim Kopf_Zeile As Integer, Kopf_Spalte As Integer
Dim Letzte_Zeile As Integer, Letzte_Spalte As Integer
Dim Laenge() As String
Dim Wand As Boolean
Dim Zufallszahl_1 As Integer, Zufallszahl_2 As Integer
Dim Toeszli_Adresse As String
Dim Groesse As Integer
Dim Weg As Integer
 
Sub Snake()
 
'====================================================================
'Alles Löschen und Spaltenbreite und -höhe anpassen
'====================================================================
 
    'Cells.Select
    'Selection.ClearContents
    'Range("A1").Select
 
    Cells.Select
    Selection.ClearFormats
    Range("A1").Select
 
    Cells.Select
    Selection.RowHeight = 12
    Selection.ColumnWidth = 2.5
    Range("AU:AU").ColumnWidth = 3.5
    Range("AU30").Value = 0
    Range("A1").Select
     
'====================================================================
'Spielbereich festlegen
'====================================================================
 
    Range("J10:AM39").Select
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
     
'====================================================================
'Snake entstehen lassen
'====================================================================
 
    Dim Groesse As Integer, a As Boolean, Highscore As Integer
     
    Highscore = Sheets("Highscore").Range("B1").Value
     
    Wand = False
     
    Range("V24:Z24").Select
    Selection.Interior.Color = 5287936
     
        ReDim Laenge(4)
        Laenge(0) = "V24"
        Laenge(1) = "W24"
        Laenge(2) = "X24"
        Laenge(3) = "Y24"
        Laenge(4) = "Z24"
     
    Range("V24").Select
    Letzte_Spalte = ActiveCell.Column
    Letzte_Zeile = ActiveCell.Row
     
    Range("Z24").Select
    Kopf_Spalte = ActiveCell.Column
    Kopf_Zeile = ActiveCell.Row
'====================================================================
'"Tözli" entstehen lassen
'====================================================================
    Randomize
    Zufallszahl_1 = Int((39 - 10 + 1) * Rnd + 10)
    Zufallszahl_2 = Int((39 - 10 + 1) * Rnd + 10)
    Cells(Zufallszahl_1, Zufallszahl_2).Interior.Color = 1521525
     
'====================================================================
'Snake laufen lassen
'====================================================================
    Dim j As Integer, Zaehler As Integer
     
    Weg = 1
     
    Do
     
        Select Case Weg
             
            Case 1
             
                If ActiveCell.Offset(0, 1).Interior.Color = 1521525 Then
                     
                    Range("AU30").Value = (Range("AU30").Value + 10)
                     
                End If
                If ActiveCell.Offset(0, 1).Interior.Color = 5287936 Then
                     
                    GoTo G2
                     
                End If
                 
            Case 2
             
                If ActiveCell.Offset(0, -1).Interior.Color = 1521525 Then
                     
                    Range("AU30").Value = (Range("AU30").Value + 10)
                     
                End If
                If ActiveCell.Offset(0, -1).Interior.Color = 5287936 Then
                     
                    GoTo G2
                     
                End If
                 
            Case 3
                 
                If ActiveCell.Offset(-1, 0).Interior.Color = 1521525 Then
                     
                    Range("AU30").Value = (Range("AU30").Value + 10)
                     
                End If
                If ActiveCell.Offset(-1, 0).Interior.Color = 5287936 Then
                     
                    GoTo G2
                     
                End If
                 
            Case 4
             
                If ActiveCell.Offset(1, 0).Interior.Color = 1521525 Then
                     
                    Range("AU30").Value = (Range("AU30").Value + 10)
                     
                End If
                If ActiveCell.Offset(1, 0).Interior.Color = 5287936 Then
                     
                    GoTo G2
                     
                End If
        End Select
         
        Range(Laenge(0)).Select
         
        If ActiveCell.Address = Toeszli_Adresse Then
             
            Selection.Interior.Pattern = xlNone
            Groesse = UBound(Laenge) + 1
            ReDim Preserve Laenge(Groesse)
            Range(Laenge(Groesse - 1)).Select
             
            Select Case Weg
             
                Case 1
                    Laenge(Groesse) = ActiveCell.Offset(0, 1).Address
                Case 2
                    Laenge(Groesse) = ActiveCell.Offset(0, -1).Address
                Case 3
                    Laenge(Groesse) = ActiveCell.Offset(-1, 0).Address
                Case 4
                    Laenge(Groesse) = ActiveCell.Offset(1, 0).Address
                 
            End Select
             
            Range(Laenge(0)).Select
            Zaehler = Zaehler + 1
        Else
         
            Selection.Interior.Pattern = xlNone
            Zaehler = 0
             
        End If
         
        For j = 0 To (UBound(Laenge)) - 1
         
            Laenge(j) = Laenge(j + 1)
         
        Next j
         
        Range(Laenge(j)).Select
         
        If Zaehler = 0 Then
         
            Select Case Weg
         
                Case 1
                    ActiveCell.Offset(0, 1).Select
                Case 2
                    ActiveCell.Offset(0, -1).Select
                Case 3
                    ActiveCell.Offset(-1, 0).Select
                Case 4
                    ActiveCell.Offset(1, 0).Select
                 
            End Select
                 
        End If
         
         
        If Selection.Interior.Color = 1521525 Then
         
            Toeszli_Adresse = ActiveCell.Address
            Dim k As Integer
G1:
            Randomize
            Zufallszahl_1 = Int((39 - 10 + 1) * Rnd + 10)
            Zufallszahl_2 = Int((39 - 10 + 1) * Rnd + 10)
             
            For k = 0 To Groesse
                 
                If Cells(Zufallszahl_1, Zufallszahl_2).Address = Laenge(k) Then
                 
                    GoTo G1
                End If
             
            Next k
             
            Cells(Zufallszahl_1, Zufallszahl_2).Interior.Color = 1521525
         
        End If
         
        Selection.Interior.Color = 5287936
        Laenge(j) = ActiveCell.Address
         
        If Weg = 1 Then
            If Selection.Borders(xlEdgeLeft).Weight = xlMedium Then
             
                MsgBox ("Verloren!!!!!!!")
                Wand = True
                GoTo G3
                 
            End If
        End If
         
        If Weg = 2 Then
            If Selection.Borders(xlEdgeRight).Weight = xlMedium Then
             
                MsgBox ("Verloren!!!!!!!")
                Wand = True
                GoTo G3
                 
            End If
        End If
         
        If Weg = 3 Then
            If Selection.Borders(xlEdgeBottom).Weight = xlMedium Then
             
G2:
                MsgBox ("Verloren!!!!!!!")
                Wand = True
                GoTo G3
                 
            End If
        End If
         
        If Weg = 4 Then
            If Selection.Borders(xlEdgeTop).Weight = xlMedium Then
             
                MsgBox ("Verloren!!!!!!!")
                Wand = True
                GoTo G3
                 
            End If
        End If
         
        Dim Start As Double
        Start = Timer
        While Timer < Start + 0.1
         
            DoEvents
             
        Wend
     
    Loop While 0 = 0
G3:
    If Range("AU30").Value > Highscore Then
         
        Sheets("Highscore").Select
        ActiveSheet.Unprotect Password:="1234"
        Range("B1").Select
        Selection.Value = Sheets("Snake").Range("AU30").Value
        MsgBox ("WOW, neuer Highscore :D")
        Sheets("Highscore").Select
        ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="1234"
        Sheets("Snake").Select
        Range("A1").Select
         
    End If
     
End Sub
Sub Rechts()
 
    Weg = 1
 
End Sub
 
Sub Links()
 
    Weg = 2
     
End Sub
 
Sub Rauf()
 
    Weg = 3
         
End Sub
 
Sub Runter()
 
    Weg = 4
     
End Sub

 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
10.02.2011 09:59:15 Samse
NotSolved
10.02.2011 10:11:15 Severus
NotSolved
10.02.2011 10:28:58 Samse
NotSolved
10.02.2011 10:44:52 Severus
NotSolved
10.02.2011 10:47:54 Samse
NotSolved
10.02.2011 10:58:03 Severus
NotSolved
10.02.2011 11:08:48 Samse
NotSolved
10.02.2011 12:01:51 Severus
NotSolved
10.02.2011 12:40:19 Gast44226
NotSolved
10.02.2011 12:56:19 Severus
NotSolved
10.02.2011 13:01:39 Samse
NotSolved
10.02.2011 14:57:29 Severus
Solved
10.02.2011 15:55:45 Samse
NotSolved
11.02.2011 07:55:02 Severus
NotSolved
Rot Rot Keydown wie geht das?
01.03.2011 14:28:05 Samse
NotSolved