Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

SendMessage And WM_GETTEXT Crashes VB6

EDIT: Go to bottom of postI have tried to go about doing this in so many different ways, but they all result in the same thing: After sending the message to my target, VB6 "Closed unexpectedly, please tell Microsoft about this error....", etc. I am trying to retrieve the text of Internet Explorer's status bar.
'(from module)Public Const WM_GETTEXT = &HDPublic Const WM_GETTEXTLENGTH As Long = &HEPublic Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long- - -- - -- - - - -- - - - - - - -- - - - - -- - - - -- - -- - Dim lngLen& Dim szBuffer$ lngLen = SendMessage(hWndStatusBar, WM_GETTEXTLENGTH, 0&, 0&) szBuffer = Space$(lngLen) SendMessage hWndStatusBar, WM_GETTEXT, lngLen, szBuffer Debug.Print szBuffer
I am positive that the hWnd is correct as it matches the one that Spy++ and the AutoIt window tool displays. If you feel it is necessary I include the code used to derive the child hWnd, it's not a problem. Is IE's status bar protected from WM_GETTEXT perhaps?I have tried doing the code many different ways, i was orignally doing it without setting space() to the buffer first, but even after doing that, it still crashes. All help is appreciated.EDIT::: Ended up just using SHDocVw and Microsoft Internet Controls instead. Much easier, haha.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
SendMessage/WM_GETTEXT Help

I want to pull text from this window in my QWS3270 program ( basically it's a a 3270 emulation application that allows PCs to connect to IBM mainframes over a TCP/IP connection).

Anyhow, the main window's class is QWS3270X, and the window I want to get text from is called ChildClass

However, when I SendMessage WM_GETTEXT, it keeps returning zero, even when there is clearly stuff there.....

Is there some other command I can use to pull the information? I'm not sure what type of control it is.... my code is correct too, it is finding the right windows, just returning ZERO when I want to get the text...

any help? thx.


this is quite a newb question, but then again I am a newb VB scripter...

I just dont get how WM_GETTEXT works with SendMessage,
my test is down below, plz tell me whats wrong.

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_GETTEXT = &HD

Private Sub Form_Load()
Dim lHwnd As Long
Dim lText As String
lHwnd = FindWindow(vbNullString, "Untiteled - Notepad")
SendMessage lHwnd, WM_GETTEXT, 256, lText
MsgBox lText & " - " & lHwnd
End Sub

Can anyone explain to me how it works?

Call SendMessage(hwnd1, WM_GETTEXT, iLength, ByVal ReceivedText)

gets a Bad DLL Calling Convention

If I remove the ByVal I get some automation errors.

Please help.

P.S. Everything is declared, all hWnd's are working, iLength is a non-zero Long from WM_GETTEXTLENGTH, and WM_SETTEXT works.

Tom Young, 14 Year Old
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer

Hi all,

I'm trying to capture the text from a popup window (i.e. a MsgBox). The code


Dim lHandle As Long
Dim length As Long
Dim result As Long
Dim strtmp As String

lHandle = FindWindow(vbNullString, "Some Popup")

If lHandle <> 0 Then

length = SendMessage(lHandle, WM_GETTEXTLENGTH, ByVal 0, ByVal 0) + 1

strtmp = Space(length - 1)
result = SendMessage(lHandle, WM_GETTEXT, ByVal length, ByVal strtmp)

End If

gives me the title of the popup window ('Some Popup') but not the msg on the
popup. How kan I get the message?

Postmessage &amp; WM_GETTEXT
Sorry ladies and gentlemen, but i still have one question on this matter. I have the handle of a custom made control on an external application and i need to get the text out of it. I can get its handle, but thats about it. I asked the dood who wrote the program, and he said its not based on any common controls as they couldn't do what he needed the "textbox" to do. I've studied this issue little bit and came up with the solution that after getting the "controls" handle, i need to use the postmessage/sendmessage with the wm_gettext parameter with it. But, i didn't have any luck with this.

Heres the main part of the code:

WindowHandle = findwindow(vbnullstring, "Programs title")
ControlHandle = findwindowex(WindowHandle, byval 0&, "ChatTextClass", vbnullstring)
Call SendMessage(ControlHandle, WM_GETTEXT, 0, textstring)

It would seem that this should result to to the text to be copied to the textstring-variable, but it doesn't return me anything, not 0 or 1, just nothing. Any help would be appreciated.

Wm_gettext -- Improper Use?
Im trying to retrieve the text from a deadAIM message, I click command1 and combo1 fills with all the open/tabbed IMs, then i click command3 to get the text contained in the window but i'm having so many problems that its ridiculous, ive tried many different methods and examples ive seen posted but each fails in its own unique way. Right now with the code contained richtextbox1 fills with a number( i think the # of chars contained in the textbox but im not sure) can anyone tell me why it wont grab the text and what im doing wrong? I would really appreciate any help as for me, being quite horrible at programming ... i .. really dont know what to do

Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessageByNum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const BM_SETCHECK = &HF1
Private Const BM_GETCHECK = &HF0
Private Const CB_GETCOUNT = &H146
Private Const CB_GETLBTEXT = &H148
Private Const CB_SETCURSEL = &H14E
Private Const LB_GETCOUNT = &H18B
Private Const LB_GETTEXT = &H189
Private Const LB_SETCURSEL = &H186
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Const VK_SPACE = &H20
Private Const WM_CHAR = &H102
Private Const WM_CLOSE = &H10
Private Const WM_GETTEXT = &HD
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_SETTEXT = &HC

Private Sub Command1_Click()

Dim lhWndParent As Long, lhWndChild As Long, lCaption As Long
Dim buf As String * 256
Dim winTitle As String
Dim winLength As Long
lhWndParent = FindWindow("DeadAIM_TabbedIM", vbNullString)
lhWndChild = FindWindowEx(lhWndParent, lhWndChild, "AIM_IMessage", vbNullString)
If lhWndChild Then

winLength = GetWindowText(lhWndChild, buf, Len(buf))
winTitle = Left$(buf, winLength)

Combo1.AddItem winTitle

End If
Loop While lhWndChild
End Sub

Private Sub Command3_Click()
Dim lResult As String
Dim sText As Long
Dim lhWndParentx As Long, lhWndChildx As Long, lhWndParentxx As Long
Dim wincaption As String
Dim lngNotepad As Long, editx As Long
Dim theshiz As String
Label1.Caption = Combo1.Text
wincaption = Label1.Caption
lhWndParentx = FindWindow("DeadAIM_TabbedIM", vbNullString)
'lhWndParentxx = FindWindowEx(lhWndParentx, 0&, "AIM_IMessage", wincaption)
lhWndParentxx = FindWindowEx(lhWndParentx, 0&, "AIM_IMessage", wincaption)

lhWndChildx = FindWindowEx(lhWndParentxx, 0&, "WndAte32Class", "AteWindow")
lhwndchildxx = FindWindowEx(lhWndChildx, 0&, "Ate32Class", 0&)
' RichTextBox1.Text = GetText(lhWndChildx)

theshiz = SendMessage(lhWndChildx, WM_GETTEXT, 0&, 0&)

RichTextBox1.Text = theshiz

End Sub

Wm_gettext + Ss_icon
have anybody experience with that kind of thing. I try to get the text from a control and also the icons in the control Like For example:


i try google and search around this forum but no luck

WM_GETTEXT With Richtextbox
is there away you can use WM_GETTEXT or something similar to also get colours, pictures etc from a rich text box. because atm all i get is the plain text.



I'm trying to get the text out of another apps "RICHEDIT" using the usual code (which i found on this board):

hw = 1180618
If hw Then
chw = FindWindowEx(hw, 0, "RICHEDIT", vbNullString)
If chw Then
n = SendMessage(chw, WM_GETTEXTLENGTH, 0&, ByVal 0&)
If n > 0 Then
s = Space$(n + 4)
SendMessage chw, WM_GETTEXT, n, ByVal s
Text1.Text = s
Text1.Text = "No text!"
End If
End If
End Sub
This code works perfect on a WordPads "RICHEDIT50W" but on that apps "RICHEDIT" it doesn't. It returns the right text length but no text.
I also tried "" from Birchy (found here: ) which also shows no text for the "RICHEDIT".

I logged the messages send by the above code:
to WordPad:


<04816> 000E0776 S WM_GETTEXTLENGTH wParam:00000000 lParam:00000000
<04817> 000E0776 R WM_GETTEXTLENGTH cch:14 [lResult:0000000E]
<04818> 000E0776 S WM_GETTEXT cchTextMax:14 lpszText:0006F670 [wParam:0000000E lParam:0006F670]
<04819> 000E0776 R WM_GETTEXT cchCopied:13 lpszText:0006F670 ("h") [lResult:0000000D]

to the other app:


<00475> 000206F2 S WM_GETTEXTLENGTH wParam:00000000 lParam:00000000
<00476> 000206F2 R WM_GETTEXTLENGTH cch:705 [lResult:000002C1]
<00477> 000206F2 S WM_GETTEXT cchTextMax:705 lpszText:0012ED2C [wParam:000002C1 lParam:0012ED2C]
<00478> 000206F2 R WM_GETTEXT cchCopied:0 lpszText:0012F65C ("<check>: Hello...") [lResult:00000000]

Why is cchCopied=0 when lpszTest has actually some text....

Any ideas on that? Maybe I need to user other messages?


Ps: Great board and great ppl! Found so many solutions here.

Retrieving Text With Wm_gettext
I'm using the below code to try and get the text from an aim instant message window. It finds the window and I can send text to the textbox but whenever I try and get the text from the textbox, wm_gettextlength returns 0 and wm_gettext also returns nothing. Please help going crazy.

Dim aimimessage As Long, wndateclass As Long, ateclass As Long
aimimessage = FindWindow("aim_imessage", vbNullString)
wndateclass = FindWindowEx(aimimessage, 0&, "wndate32class", vbNullString)
ateclass = FindWindowEx(wndateclass, 0&, "ate32class", vbNullString)
Dim TheText As String, TL As Long
TL = SendMessageLong(ateclass, WM_GETTEXTLENGTH, 0&, 0&)
TheText = String(TL + 1, " ")
Call SendMessageByString(ateclass, WM_GETTEXT, TL + 1, TheText)
TheText = Left(TheText, TL)

Help Getting Text From A Weird Textbox With WM_GETTEXT
theres this game i play its a text game and the textbox that has all the words in it has a caption property and i cant figure out how to get the text inside the window, can someone help me out please, i think i could with sendtext and WM_GETTEXT but i dont know how to use them, i have the window's handle already too.
EDIT: i got wm_gettext to work, but it only retrieves the caption of the window/textbox...i think its a usercontrol, if it was how would i get the handle for the textbox?i already tried finding more child windows, but it returned a zero with FindWindowEx(GHWND, GW_CHILD) and i know i have the right window handle because i tried WM_SETTEXT and changed the text of the usercontrol, but i cant get the text inside of the usercontrol.pllease help

API - WM_GETTEXT Is Failing To Work Correctly....

I am using the postmessage function and the WM_GETTEXT constant to obtain the text from a window but it doesnt want to work with this one window. The coding I have works on other windows but for some reason I can not get the text from this particular window. It is not a password box or anything, its just a window. I checked to make sure it was enabled and it is enabled. Does anyone know how I can get the text from the window or have any ideas why I can't get the text? Thanks.

Code segment I am using:

' Display the title bar text of window Form1 by sending the
' appropriate messages to it.
Dim wintext as string ' receives the copied text from the target window
Dim slength as Long ' length of the window text
Dim retval as Long ' return value of message

' First, determine how much space is necessary for the buffer.
' (1 is added for the terminating null character.)
slength = SendMessage(wnd, WM_GETTEXTLENGTH, byval CLng(0), byval CLng(0)) + 1
' Make enough room in the buffer to receive the text.
wintext = Space(slength)
' Copy the target window's text into the buffer.
retval = SendMessage(wnd, WM_GETTEXT, byval slength, byval wintext)
' Remove the terminating null and extra space from the buffer.
wintext = Left(wintext, retval)
' Display the result.
List1.AddItem wintext


VB6 Crashes After Myapp Crashes In Debug
I am running VB6 with Service Pack 6. Also SourceSafe 6.0 is loaded.
The Operating System is Windows XP (SP2).

When I am debugging an application and my application crashes for some reason, the next time I start to debug the aplication VB will crash, and I loose any work not saved.

This also happens if I am debugging and I stop the application using the IDE.

Can anyone let me know how to fix this?

Window Doesn&#039;t Paint Properly, Scroll, After Recieving WM_GETTEXT
^----- top.

Why would sending these messages mess with the window's scrolling and painting?

GDI+ Crashes IDE
I was wondering if anyone can help.
I am using the GDI+ tlb from OnErr0r (v6).

As a test I am using the code from the verision5 sample
to load the png from the v5 resource file.
(Note: The TLB is the version 6, as I deleted the version 5.)

What I am doing is placing almost identical code used in v5
into a Usercontrol and attempting to draw the the image
on mouse up and down.

I am using the image in the resource file so hopfully
anyone can reproduce the error.

Once I run the code, it will either crash the IDE immediately, or
if it runs it will crash the IDE when exiting the program.

I have posted the code below.

Any help would be great.

Thanks in advance,

' ***** START CODE ****************
Dim bmp1 As cBitmap
Dim bmp2 As cBitmap
Dim graphics1 As cGraphics

Dim mState As Integer

Private Sub UserControl_Initialize()
Set bmp1 = New cBitmap
Set bmp2 = New cBitmap
Set graphics1 = New cGraphics

bmp1.CreateFromResource 101
bmp2.CreateFromResource 101
graphics1.CreateFromHDC UserControl.hDC

mState = 0
End Sub

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If mState <> 1 Then
mState = 1
End If
End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If mState <> 0 Then
mState = 0
End If
End Sub

Private Sub UserControl_Paint()
If mState = 0 Then
graphics1.DrawImageI bmp1.Handle, 0, 0
graphics1.DrawImageI bmp2.Handle, 50, 50
End If
End Sub

Private Sub UserControl_Terminate()
Set bmp1 = Nothing
Set bmp2 = Nothing
Set graphics1 = Nothing
End Sub

' ***** END CODE ****************

Ocx Crashes VB
I have just written a simple (hah!) ocx, a text box which accepts only integers. There are only two properties, a maximum and minimum value, and error handlers for these in the text box validate event.
In the VB development environment it works perfectly - if a set "maximum" to 90 and then enter 100, the event fires, I get my nessage box up, beep, and it's AOK.
I compiled it and added it to a form to test it there. As soon as the error was generated, the whole VB environment crashed! No message box, just FATOOM - VB closed.
This is the first time I've done this, and used Karl Moore's excellent tutorial for training:

Anyone know what's going wrong?

VB6 Crashes!
it's already solved...

Vb6 Crashes :(
I never had problems running Vb 6.0 , I didn't use it for several weeks. Yesterday I wanted to start it again, loaded a project but Vb crashed when I tried to watch the objects (shift +f7). I tried several other projects but they all crash when I try watching the objects.

The crash report (dutch language) says:

VB6 heeft een fout met betrekking tot een ongeldige pagina veroorzaakt in
module VB6.EXE op016f:004581f1.

I reinstalled visual basic, but it didn't help... any suggestions ?

App Crashes Out

I'm not sure quite what I'm doing wrong here..... ON ERROR won't catch it, either.

I have created a "hacked" .DLL file as per the instructions found here:

The DLL works, but the following code just crashes without warning. I can't remember where this code came from (if anyone is aware that it is patented or requires a license to use, please let me know - I'm using it here for fun).

The code in the DLL is thus:

Public Function RC4(Expression As String, Password As String) As String
On Error Resume Next
Dim RB(0 To 255) As Integer, X As Long, Y As Long, Z As Long, Key() As Byte, ByteArray() As Byte, Temp As Byte
If Len(Password) = 0 Then
Exit Function
End If
If Len(Expression) = 0 Then
Exit Function
End If
If Len(Password) > 256 Then
Key() = StrConv(Left$(Password, 256), vbFromUnicode)
Key() = StrConv(Password, vbFromUnicode)
End If
For X = 0 To 255
RB(X) = X
Next X
X = 0
Y = 0
Z = 0
For X = 0 To 255
Y = (Y + RB(X) + Key(X Mod Len(Password))) Mod 256
Temp = RB(X)
RB(X) = RB(Y)
RB(Y) = Temp
Next X
X = 0
Y = 0
Z = 0
ByteArray() = StrConv(Expression, vbFromUnicode)
For X = 0 To Len(Expression)
Y = (Y + 1) Mod 256
Z = (Z + RB(Y)) Mod 256
Temp = RB(Y)
RB(Y) = RB(Z)
RB(Z) = Temp
ByteArray(X) = ByteArray(X) Xor (RB((RB(Y) + RB(Z)) Mod 256))
Next X
RC4 = StrConv(ByteArray, vbUnicode)
End Function
The code I'm executing in my main app looks like this:

Option Explicit
Private Declare Function RC4 Lib "Test.dll" (ByVal Expression As String, ByVal Password As String) As String

Private Sub mnuTest_Click()
On Error GoTo err
MsgBox "Test " & RC4("message", "Password87tgoi yg0987 touyg"), vbOKOnly, ""

Exit Sub


MsgBox err.LastDllError & vbCrLf & err.Number & vbCrLf & err.Description, vbOKOnly, ""

End Sub
Is it the way I'm calling the RC4 function from a message box? I'm only using that as a quick output.

The DLL is compiled; it isn't running as another instance in memory. It does work for other functions, just not this one. I wondered if it might be due to the way I'm referencing it?

Best regards,

VB6 App. Crashes When Run From Exe
Hi All,
A very simple application runs once or twice from the exe then on the third time it is crashing but it works fine if I run it from the code. very weird!!

A DB connection using OraOLE provider.
A recordset running a query and return the recordcount in a MsgBox.
This is my code:

Dim lRS As ADODB.Recordset

Set lRS = New ADODB.Recordset

Set lRS = mConnection.Execute(lQuery)

MsgBox lRS.RecordCount
Set lRS = Nothing
I compiled and run the exe after executing once or twice, the third time the application crashes.
When I run from VB there is no problem it runs 100s of time without any problem.
I put an error handler and it is not even getting there, the whole app crashes.
I changes the compile parameters to compile to P-Code, Native Code... and no luck
I appreciate your suggestions...

VB IDE Crashes - HELP!
I'm creating an application which sits in the systray. It's currently incomplete but i'm posting what I have, which is runnable.

I'm using this DLL located here to add an icon to the systray:

You'll need to download this project and compile the dll to your windows system directory. (Unless you can figure out the problem without it =) )

Whenever I try to end the program, it crashes the IDE in frmPopup after I click mnuExit. If I remove the "End" statement from frmPopup_Unload() event it doesn't crash, but the program doesn't end.

How do I end the program without crashing the IDE?

About Crashes...
Is there a way to call a function when a crash occurs in a program.
I would like to save the environment just before a crash occurs...
Somebody knows if there is a global way to do this ?

VB Crashes
I am working on a program and making minor changes. VB 6.0 is now crashing quite often. It is not crashing at the same point in the program and it is not the same error code when it crashes so I am assuming it is a problem with VB not the program. Some of the errors I have gotten are "access Violation", "unknown error" etc. What can I do to fix this??
Thanks in advance

VB Crashes
Yeah.. I'm making an app that relies on WinSock, but then, when the app closes BEFORE my VB app does, it crashes my VB, though it works if I close it normally. There is any way to avoid that crash in VB 6.0 ? If anyone needs code for helping or anything, tell me

VB6 Crashes
I have both VB6 and VB.NET on my machine. The programs I write are in VB6 as I have not yet mastered VB.NET. This has caused me no problem until the last week.

When I am testing any code for a new program and the code fails for any reason, rather then the error message and highlighted code I would normally get, the system crashes. The error messages are as follows:

"VB has encountered a problem and needs to close." When I click on the DeBug button I get another message. "An exception 'unhandled Win32 exception' has occured in VB6.EXE. Possible Debuggers...New instance of Visual Studio Net 2003"

I'm at a loss as to what to do to fix the problem. having to exit VB every time there is an error is a real pain,

VB6 SP5 And XP Pro SP1 Causes Crashes
When I am in the VB IDE and writing code at undetermined times the IDE crashes causing a 1000 and 1001 event. I can walk away from my PC and maybe after 4 or 5 minutes it will do it on its own. It happens in different projects with various components added (all microsoft - no third party stuff)

Here are the events

1000 event

0000: 41 70 70 6c 69 63 61 74 Applicat
0008: 69 6f 6e 20 46 61 69 6c ion Fail
0010: 75 72 65 20 20 76 62 36 ure vb6
0018: 2e 65 78 65 20 36 2e 30 .exe 6.0
0020: 2e 38 39 2e 38 38 20 69 .89.88 i
0028: 6e 20 75 6e 6b 6e 6f 77 n unknow
0030: 6e 20 30 2e 30 2e 30 2e n 0.0.0.
0038: 30 20 61 74 20 6f 66 66 0 at off
0040: 73 65 74 20 35 64 33 32 set 5d32
0048: 31 61 39 35 0d 0a 1a95..

1001 event

0000: 42 75 63 6b 65 74 3a 20 Bucket:
0008: 33 36 38 31 31 34 32 38 36811428
0010: 0d 0a ..

It does not happen under Win95, Win98, WinME or Win2000 .... Only with this new Dell with XP Pro

Nobody at microsoft's vb.bug forums has a clue and barly anyone else has this problem and they are as stumped as I am.

Also, anyone got SP6 Beta yet? and is it worth trying?

Thanks in advance

VB Crashes Awfully! Help Please!
Hey guys,

I have this huge problem, the app crashes awfully with the horrifying "Program Error: VB6.exe has generated errors and it will be closed by windows...." , this is whats going on:

thankz to everyone here I have managed to send some data I receive from the serial port to wherever the caret is at the time, the app does something like this:

I set the windowstate to 1 to to minimize my app and to pass the active window to the next in the z order (which is the one behind!), normally this goes ok, then I simulate that the incoming data from the serial port is beign typed from the keyboard with this nice sub:

Option Explicit

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SHIFT = &H10
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal cChar As Byte) As Integer
Private Declare Function CharToOem Lib "user32" Alias "CharToOemA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Private Declare Function OemKeyScan Lib "user32" (ByVal wOemChar As Long) As Long
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long

Public Sub WriteText(ByVal sKeys As String)
Dim VK As Integer
Dim nShiftScan As Integer
Dim nScan As Integer
Dim sOemChar As String
Dim nShiftKey As Integer
Dim i As Integer
For i = 1 To Len(sKeys)

If Not ok Then
buffer = ""
Exit Sub
End If

'Loop through entire string being passed
'and send each character individually.

'Get the virtual key code for this character
VK = VkKeyScan(Asc(Mid(sKeys, i, 1))) And &HFF

'See if shift key needs to be pressed
nShiftKey = VkKeyScan(Asc(Mid(sKeys, i, 1))) And 256
sOemChar = " " '2 character buffer
'Get the OEM character - preinitialize the buffer
CharToOem Left$(Mid(sKeys, i, 1), 1), sOemChar
'Get the nScan code for this key
nScan = OemKeyScan(Asc(sOemChar)) And &HFF

'Send the key down
If nShiftKey = 256 Then
'if shift key needs to be pressed
nShiftScan = MapVirtualKey(VK_SHIFT, 0)
'press down the shift key
keybd_event VK_SHIFT, nShiftScan, 0, 0
End If

'press key to be sent
keybd_event VK, nScan, 0, 0

'Send the key up
If nShiftKey = 256 Then
'keyup for shift key
keybd_event VK_SHIFT, nShiftScan, KEYEVENTF_KEYUP, 0
End If

'keyup for key sent
keybd_event VK, nScan, KEYEVENTF_KEYUP, 0
End Sub

Of course this goes immediately to where the caret is since my app is minimized and the active window is for example notepad. Everything is ok but when I try to stop the transmission restoring my app (I do this in form1_resize) something is wrong and crashes with no remedy! this is what I do to solve the problem Im still getting it

Private Sub Form_Resize()
buffer = "" 'I receive here MSComm1.input
If Me.WindowState = 0 Then
SetForegroundWindow Form1.hwnd 'Try to force setting form1 to foreg
ok = false 'check WriteText above
If MSComm1.PortOpen Then
MSComm1.PortOpen = False
End If
Command2.SetFocus 'set the focus somewhere in form1
End If
End Sub

I believe it has something to do with the focus, also I debug and all goes nice, just when I let it fly by its own the app crashes! Another thing: ok is set to prevent to keep writing to the keyboard when I halt the transmission...

Help please!

VB Crashes
Dear I all I am getting this error and vb closes.I don't know why.

VB Code:
'read a lineCall SendMessage(RTB.hwnd, EM_GETLINE, lLinenumber, ByVal Buffer1)'HighlightlineCall SendMessage(RTB.hwnd, EM_SETSEL, chrsToStart, ByVal chrsToEnd)'Delete the lineRTB.seltext=""

Will excessive use of sendmessage will result in this kind of error?

VB6 Crashes
The IDE will crash if i type in code like this:

VB Code:
ReDim Some(0 To 1).Aa(1)

VB Crashes
Hi im working with vb 6 and after a few seconds (sometimes minutes) of working it just crashes.

the following is diplayed:


Visual Basic has encountered a problem and needs to close. We are sorry for the inconvenience.

It's one of those "send error report" windows. I've uninstalled vb6 and reinstalled to no avail. please can someone help it's quite frusutrating. I cant do anything in vb.

the error information details are


AppName: vb6.exe AppVer: ModName: vb6.exe
ModVer: Offset: 000581f1

thanx in advance

VB Crashes
When I try to add a component in Visual Basic e.g. the WinSock control VB crashes.

Has anyone ever had this problem and if so, how did you fix it.

I am using Windows 2000 and VB v6.0, some of the other computers are using the same setup but they can add components....


Getting Crashes With FSO! Help
Ok, I have a ActiveX DLL that I wrote in VB6 on a WinXP box. The DLL is actually being used as a Winamp plugin.Now, the DLL works perfect with WinXP. But on a Win98 machine, when I set the following, I get a 'Type 13 Mismatch' error.

VB Code:
Set fso = CreateObject("Scripting.FileSystemObject")

I'm using the scrrun.dll file that came with Win98. Should I use a newer version? Will the one XP has work with Win98? How can i be sure of compatibility here?


Vb Crashes
when i retrieve access an object, in fact the same object, when i copymemory the pointer from a long i earlier stored by copying the pointer. The same object still exists, it's just that vb crashes the second time, but not the first.

anything similar occcured to you?

VB6 SP4 Crashes On Win 98 - Help!
Please reply if you know of anything that might help:

I had VB6 Professional installed on Win98 on a laptop and downloaded SP4 (+ mdac 2.5) from the microsoft website. What happened ??
VB6 hangs on the splash screen indefinetely - no more VB.

I then did a clean reinstall of Win98 and VB6 (without the SP4 this time). And now sometimes it hangs and sometimes it doesn't....

Is it software or perhaps hardware that's giving up???

VB6 IDE Crashes
If anybody has an answer/ suggestion on this one, I'd really appreciate it. Out of the blue, the VB IDE (Visual Studio 6.0) will crash whenever I try to display a Form that contains any kind of control. Fine with a new blank form, but anything heavier, it closes without any messages. It will display code OK, and existing projects will run as before. It's just trying to "Show Object" that brings it down. I suspect some change to a system file, but have no idea when or what. Also, a fresh install of VS6 and SP6 and a full SFC of XP-SP2 didn't solve it.
thanks for any ideas

VB Crashes!!!
Hey something has gone wrong with my VB6!!!!
Whenever I run a form with a label/textbox/picture in it VB crashes!!!
It just gives me that "Send Error Report" dialog box!!!!
Please help me....
I don't wanna re-install VB6 for fear of losing my existing programs(there are hundreds)...
I dunno if it'll be alright if I just backup all the forms/modules/projects etc and re-install!!!!
Please help!!!!!

VB Crashes
Whenever I try to add external component to my vb application, it will crash. Did anyone had this problem? I'm using VB5 on NT workstation 4.0 with the latest SP6 128-bit.

VB Crashes
I have a dedicated form with CrystalViewer control on it. In other forms I prepare Report object, assign it to CrystalViewer control on that form, then display that form. So far everything works fine. But when I close that form it might crash VB.
It happens with reports which have at least 2 subreports. If only 1 subreport or no subreports at all then everything is fine.
All reports initially were created to work with SQL Server Stored Procedures. They were working, but were too slow and I decided to use recordsets created in VB and populated from the same SPs. Reports became much faster, but I've got a problem with crashing. I tryed to keep all recordsets open all the time, I tried to close them after report is populated with data. The same behaviour.
I tied to replace the report in CrystalViewer control with an absolutely blank fake report before closing the form. The same result on closing form - crash.

Any idea why it happens?
Thank you

Installed SP5 And Now VB6 Crashes!!!!
I wasn't having this problem before and I didn't even have any of the 5 Service Packs. Well i started noticing a bug in SSTab and figured it was a good time to install the service pack. I installed SP5 and now when I try to instantiate an object.

Dim oAccess as Access

set oAccess = '..this is when it crashes, after I type the equal sign

any idea? can I uninstall this service pack?


OK In Development, .exe Crashes
My program works fine in the development environment & compiles without apparent problems. However, when I run it (on the same PC, after having installed it with the Package & Deployment wizard), it crashes on several forms. The crash is always the same: the form is frozen at first, but clicking on the form or any of a number of other controls makes all controls accessible. However, clicking on certain controls cause it to bomb, with the message "Error 400 - form already displayed; can't show modally." What gives?

Thanks for any suggestions.

DrawIndexedPrimitive W/ SW-VP Crashes
I am using Visual Basic 6 with DirectX 8.1 and I found that making calls to the DrawIndexedPrimitive to a card that only supports Software Vertex Processing frequently causes the application (along with the VB IDE) to crash.

When using a card with Hardware Vertex Processing everything works great, but if I use Software Vertex Processing on the same card then it crashes.

Does anyone have any idea what the problem is?


Printing And Then It Crashes
What's wrong with this code:

Private Sub Command2_Click()
Dim objWord As Word.Application
Dim objDoc As Word.Document
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add(App.Path & "word")
objDoc.Variables("naam").Value = "Reinier den Hollander"
objDoc.Close wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing
End Sub

When I click the command2 button it thinks and it thinks and it won't print. What is wrong? did i forget something?

VB Crashes With Usercontrols
Hi there,

I have a strange problem. I had to reinstall windows 4 weeks ago,
and now that I installed all tools, programs etc. I wanted to continue
a project, so I installed VB6, loaded my project, opened a form and..
VB closed without any error.
After a bit (or maybe more than a bit) of research, I found out that
it has to do with usercontrols. I tracked it down to usercontrols
that have the UserControl_Initialize or _Resize sub in them, even
if those subs are empty.
I can do the following:
Start a new project
Add a usercontrol
Add an empty sub named UserControl_Initialize()
Add this control to Form1 -> VB crashes instantly

This makes absolutely no sense to me, I already reinstalled VB6, tried
with and without SP6, but no difference.

Although this sounds very unusual, I still thought I might ask here,
maybe there is someone who has an idea whats causing this.
The simplest solution would for sure be to reinstall windows, but
killing a working os (except for VB ) just after setting up
everything is....yeah...

Thanks in advance

VB Crashes When Using Certain Components
I tried searching the forums for similar problems, but I couldn't find any. I still hope somebody can help me:

If there is a certain component on the form, VB crashes whenever I try to save the project, compile it or just click on the form in Project Explorer window (i.e. I can't even see the form layout in VB).

So far these components cause a crash:

Microsoft Masked Edit - msmask32.ocx
Microsoft Common Controls-2 6.0 (SP4) - mscomct2.ocx

I can reference those components with no problems. But as soon as I put one of them on a form, problems start.

I tried reinstalling VB6, also regsvr32 and all, but it doesn't help...

Any ideas?

Alt-D Crashes My Program
I have an MDI app and within it we have several utility programs (mdi children). One of my mdi children launches a wizard I created (wizard = mdi child resized so that the tabs of a sstab control don't show). When I am on the first tab of the wizard, Alt-D sets focus on a combo box, because that is the hotkey I set for it's label. On the next tab, Alt-D shuts down this form (why???), and on another tab, Alt-D crashes the whole program! I can't track this down. When I try adding break points in the various keydown or keyup events when I press D it opens the Debug menu in the IDE. This is driving me bonkers. Any help would be appreciated.


See If Program Crashes

im looking for a way to see if an running application has crached. I create : lets say a server (external application), and poll it to see if its still online. But when the server craches, the server shows still online because the error message (msgbox) freeezes the server.

is there a way to see if a program is still responding or not ? so i can reboot it ?


Excel Crashes With A GPF
I've been saving my Excel template many times till now for the last two days into a file called Copiers1.xlt. Now, it has started giving me a GPF and starts crashing Excel when I save it under the same name. If I save it under a different name, it still does not save saying "Document not saved." No help button is available on the message box. What could be causing this? Please help me as I have been stuck for the last 4 hours with this and have changed several machines and re-installed Excel also but nothing seems to have changed.

RTFBox Crashes VB?
I was using a normal Textbox up to now. Since I'd like some text colored, I decided to use the MS Richt Textbox Control 6.0 (SP4) instead. Now VB crashes every time I try to close the specific form. First, I thought that my subclassing-routine is to blame but VB continues crashing without subclassing too.
After looking deeper into this matter I found that VB will crash when closing the form via the RTBox_KeyPress event.

Private Sub rtbConsole_KeyPress(KeyAscii As Integer)
Dim bFound As Boolean

Select Case KeyAscii
Case vbKeyReturn
If LCase$(Right$(rtbConsole.Text, Len(rtbConsole.Text) - InStrRev(rtbConsole.Text, ">"))) = CMD_EXIT Then
Unload Me 'so, that's the reason VB is crashing
End If

..... 'more code; nothing of relevance to this matter
End Select
End Sub

Does anybody know why this strange behavior lets the IDE crash? It seems really strange to me ...

Copyright 2005-08, All rights reserved