עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

פתרון תקלה בקוד תוכנית VB (שגיאה בזמן ריצה מס' 9)

Featured Replies

פורסם

שלום רב !!

אני כותב פרויקט ב-VB ויש לי בעיה של שגיאה בזמן ריצה שרשום בה :


run-time error '9':
subscript out of range

הקוד בו מתבצעת השגיאה הוא :


Private Sub drawWithHiding()
Dim j%, K%, L%
Dim arr(1 To moneWalls) As recordType

For j = 1 To moneWalls
arr(j).i = j
arr(j).Z = walls(j).V(walls(j).vertices, 3)
Next j
'========= מיון בועות ===========
For K = 1 To moneWalls - 1
For L = K + 1 To moneWalls
If arr(K).Z > arr(L).Z Then
swap arr, K, L
End If
Next L
Next K
'============סיום מיון בועות ותחילת ציור הגופים==========
Form2.Cls
DrawShadows Form2, table, Peres, light, vbBlue

For K = 1 To moneWalls
If arr(K).i >= 6 And arr(K).i <= 10 Then 'drew green walls
If isHit((arr(K).i) - 5) = False Then
DrawShadows Form2, walls(arr(K).i), Peres, light, vbGreen
End If
End If

If arr(K).i >= 1 And arr(K).i <= 5 Then 'drew red walls
DrawShadows Form2, walls(arr(K).i), Peres, light, vbRed
End If

If arr(K).i = 11 Then 'drew ball
DrawShadows Form2, walls(arr(K).i), Peres, light, vbYellow
End If
Next K
End Sub

והשורה בה מתבצעת השגיאה היא :


arr(j).Z = walls(j).V(walls(j).vertices, 3)

מישהו יודע מה התקלה וכיצד פותרים אותה ?

פורסם

subscript out of range = חרגת מגבולות המערך. תבדוק שאתה לא חורג מהגבולות של arr ושל walls.

פורסם
  • מחבר

לא חריגתי מהגבולות גודל שני המערכים הוא moneWalls כאשר Const moneWalls = 11..

איך פותרים את הבעיה הזאת..זה דחוווףףף..

פורסם
  • מחבר

מישהו יודע איך מסדרים את הבעיה הזאת ? זה דחחחחוווףףףףףףףףףףףף

פורסם

תדפיס לפני השורה הבעייתית למסך את כל האינדקסים שהיא משתמשת בהם.

פורסם
  • מחבר

ותכתוב כאן את ההגדרה המדוייקת של walls.

ההגדרה של walls היא :

walls(1 to moneWalls ) as gufType

הערה : gufType הוא סוג המשתנה (שנוצער על ידי) לגוף תלת-מימדי..

פורסם
  • מחבר

וההגדרה שלו היא...?


Public Type GufType
V(1 To Max_Vertices, 1 To 3) As Single '' קדקדים
P(1 To Max_Faces, 1 To Max_Vertices_Per_Face + 2) As Integer ' קירות ועוד
vertices As Long ' כמה קדקדים בפועל
faces As Integer ' כמה קירות בפועל
End Type


Const Max_Vertices = 84 ' מספר מקסימלי של קדקדים בגוף
Const Max_Faces = 94

פורסם
  • מחבר

הבעיה נפתרה....

זה היה הצבת לא נכונה של הגוף במערך..

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.