FIX: Invalid Index Passed to Screen.Fonts Collection Causes GPF |
Q180526
An application error may occur within the Windows CE emulator (pvb.exe) if an invalid index is passed to the Screen.Fonts collection. The error is as follows:
On the actual Windows CE device, this error causes the application to end without an error dialog.The instruction at "0x01000a68b" referenced memory at "0x00000034". The memory could not be "read".
Ensure that the index that is passed to the Screen.Fonts collection is valid. The following code sample shows how a function (IsValidFontIndex) can be used to ensure that the error does not occur:
Option Explicit
Private Sub Command1_Click()
Dim iFontNumber
'Set iFontNumber to an invalid Screen.Font index value.
iFontNumber = Screen.FontCount
If IsValidFontIndex(iFontNumber) Then
Command1.Font = Screen.Fonts(iFontNumber)
Else
'Insert some other error handling or set
'the font to a default font.
MsgBox "Invalid Font Index"
End If
End Sub
Private Function IsValidFontIndex(Index)
If Index >= Screen.FontCount Then
IsValidFontIndex = False
Else
IsValidFontIndex = True
End If
End Function
Microsoft has confirmed this to be a problem in the Microsoft products that are listed
at the beginning of this article.
This problem was corrected in Windows CE Toolkit for Visual Basic 6.0.
Private Sub Command1_Click()
Dim iFontNumber
'Set iFontNumber to an invalid Screen.Font index value.
iFontNumber = Screen.FontCount
'The following line of code will produce
'an application error in PVB.EXE.
Command1.Font = Screen.Fonts(iFontNumber)
End Sub © Microsoft Corporation 1999, All Rights Reserved.
Contributions by Mike Dixon, Microsoft Corporation
Additional query words: wince vbce vbce5 vbce6
Keywords : kbToolkit kbVBp kbVBp500bug kbVBp600fix kbOSWinCEsearch kbOSWinCE100 kbGrpDSVB
Issue type : kbbug
Technology : kbVBSearch kbAudDeveloper kbWinCETKVBSearch kbWinCESearch kbWinCETK100VB500
|
Last Reviewed: October 21, 1999 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |