Home > Software engineering >  VB 9 subscript bounds error
VB 9 subscript bounds error

Time:11-09

Given by the teacher, also failed to understand what you mean, when debugging is always prompt subscript bounds, seek advice,

'Private type bitmapfileheader
Bftype As Integer
Bfsize As Long
Bfreserved1 As Integer
Bfreserved2 As Integer
Bfoffbits As Long
End Type
'header
Private type bitmapinfoheader
Bisize As Long
Biwidth As Long
Biheight As Long
Biplanes As Integer
Bibitcount As Integer
Bicompression As Long
Bisizeimage As Long
Bixpelspermeter As Long
Biypelspermeter As Long
Biclrused As Long
Biclrimportant As Long
End Type
'palette
Privatae type rgbquad
Rgbblue As Byte
Rgbgreen As Byte
Rgbred As Byte
Rgbreserved As Byte
End Type
Dim bf As bitmapfileheader
Dim bl As bitmapinfoheader
Dim piccol (1024, 1024, 2) the As Byte
Dim xpos As Integer
Dim ypos As Integer
Dim picturename As String



CommonDialog1. DialogTitle="open the image file"
CommonDialog1. FileName=""
CommonDialog1. Filter="image file (*. BMP) | *. BMP"
CommonDialog1. ShowOpen
Picturename=CommonDialog1. FileName
If picturename="" Then
MsgBox "please open the image file, read the data again!" , vbCritical, "error"
The Exit Sub
End the If
Picture1. Picture=LoadPicture (CommonDialog1. FileName)
Dim colornum, I, j, kk, l As Integer
Dim pix As Byte
Dim col As Byte
The Open picturename For Binary As # 1
The Get # 1,, bf
The Get # 1, and bl
Xpos=bl. Biwidth
Ypos=bl. Biheight
Colornum=bl. Bibitcount
Screen. MousePointer=12
The Select Case colornum
A Case of 24
For I=0 To ypos - 1
For j=0 To xpos - 1
For l=0 To 2
Get the # 1, col
Piccol (j, I, l)=col
Next
Next
If the Int ((xpos * 3)/4) & lt;> (xpos * 3)/4 Then
For kk=1 To 4 - (Mod (xpos * 3) (4)
Get the # 1, pix
Next
End the If
Next
Case 8
Dim Index As Byte
Dim palentry As Byte
Dim unused As Integer
Dim rgbpalette (255, 2) the As Byte
Dim palettesize As Integer
Palettesize=2 ^ colornum
For I=0 To palettesize - 1
For j=0 To 2
The Get # 1, and palentry
Rgbpalette (I, j)=palentry
Next
The Get # 1, and palentry
Unused=palentry
If unused & lt;> 0 Then
GoTo readend
End the If
Next
Readend: For I=0 To ypos - 1
For j=0 To xpos - 1
The Get # 1, and the Index
Piccol (j, I, 0)=rgbpalette (Index of 0)
Piccol (j, I, 1)=rgbpalette (Index of 1)
Piccol (j, I, 2)=rgbpalette (Index, 2)
Next
If the Int (xpos/4) & lt;> Xpos/4 Then
For kk=1 To 4 - xpos Mod 4
Get the # 1, pix
Next
End the If
Next
End the Select
Close # 1
Screen. MousePointer=0

Print "bftype="; Bf. Bftype
Print "bfSize="; Bf. Bfsize
Print "bisize="; Bl. Bisize
Print "biwidth="; Bl. Biwidth
Print "biheight="; Bl. Biheight
Print "bibitcount="; Bl. Bibitcount
Print "bicompression="; Bl. Bicompression
Print "bisizeimage="; Bl. Bisizeimage
Print "bixpelspermeter="; Bl. Bixpelspermeter
Print "biypelspermeter="; Bl. Biypelspermeter
Print "biclrimportant="; Bl. Biclrimportant

CodePudding user response:

Which prompts the subscript crossing the line?

CodePudding user response:

Find a extracurricular teacher bai,
 
Piccol (j, I, 0)=rgbpalette (Index of 0)
Piccol (j, I, 1)=rgbpalette (Index of 1)
Piccol (j, I, 2)=rgbpalette (Index, 2)

Array problem, determine the array dimension of bai,

CodePudding user response:

Piccol (j, I, l)=col in this way, but I change the pictures, and not a mistake, don't understand the

CodePudding user response:

Look at the array as if 1024 * 1024 pixels, photo size over the cross-border is normal;
  • Related