I must not be understanding something about the use of forms in VB.Net that
is different from VB. I have one form running in the background with an icon
in the task bar. Right clicking on the icon gives you a list of options, one
of which is to show an About form. After this form shows I get an error
saying "Object reference not set to an instance of the object." I have tried
opening the form with
frmAbout.Show
frmAbout.ShowDi alog
And
Dim frmAbout2 As New frmAbout
frmAbout2.ShowD ialog()
frmAbout2.Show
But I still get the same error. How do I fix this problem?
Thanks,
Norm 10 1635
"Norm" <No****@newsgro ups.nospam> schrieb: I must not be understanding something about the use of forms in VB.Net that is different from VB. I have one form running in the background with an icon in the task bar. Right clicking on the icon gives you a list of options, one of which is to show an About form. After this form shows I get an error saying "Object reference not set to an instance of the object." I have tried opening the form with
Where exactly does the error occur? Does the IDE point to a certain line?
Which controls are you using on the form?
And Dim frmAbout2 As New frmAbout [...] frmAbout2.Show
This should basically work...
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
The complete error is
An unhandled exception of type 'System.NullRef erenceException ' occurred in
system.windows. forms.dll
Additional information: Object reference not set to an instance of an
object.
The IDE highlights the original line calling the second form after the form
shows.
I have tried this with several different forms as frmAbout and get the same
error.
Norm
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l... "Norm" <No****@newsgro ups.nospam> schrieb:I must not be understanding something about the use of forms in VB.Net
that is different from VB. I have one form running in the background with an icon in the task bar. Right clicking on the icon gives you a list of options, one of which is to show an About form. After this form shows I get an error saying "Object reference not set to an instance of the object." I have tried opening the form with
Where exactly does the error occur? Does the IDE point to a certain line? Which controls are you using on the form?
And Dim frmAbout2 As New frmAbout [...] frmAbout2.Show
This should basically work...
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Hi
Thanks for your information.
To troubleshooting the problem, can you help to build a simplest reproduce
sample and post in the newsgroup, if you have any concern, you may also
send to me via removing the "online" from the my email address.
Basically, show one form in another form will not cause the exception, I
think we need more information to troubleshooting the problem, thanks for
your efforts in advance.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Peter,
Thanks for the information, I am going to start over with a new blank form
and see how far I can get before seeing any errors. There is something weird
going on as I was able to get everything else to work, but after left
clicking on several shortcuts I would get the same error on my main form.
This has become a learning process harder than the VB6 was, but I am
determined to continue to learn.
I will let you know if I run into this error again and maybe I can track it
down a little closer. When I run the debugger the program will start without
any errors, but when I run the build executable the program throws an
exception at start up.
Thanks,
Norm
""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:R2******** *****@TK2MSFTNG XA01.phx.gbl... Hi
Thanks for your information. To troubleshooting the problem, can you help to build a simplest reproduce sample and post in the newsgroup, if you have any concern, you may also send to me via removing the "online" from the my email address.
Basically, show one form in another form will not cause the exception, I think we need more information to troubleshooting the problem, thanks for your efforts in advance. Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no
rights.
Norm wrote: Thanks for the information, I am going to start over with a new blank form and see how far I can get before seeing any errors. There is something weird
If you do get an error, print out the stack trace, which should provide
more detailed information. You can use code similar to the follow to
get the stack trace:
Try
'Code here that may generate an exception
Catch ex As Exception
Dim s As String
While Not ex Is Nothing
s &= ex.Message & ": " & ex.StackTrace
ex = ex.InnerExcepti on
End While
MsgBox(s)
End Try
Chris,
I have been unable to catch the exception, as it is now showing on the Main
form class Name, rather than in the code anywhere that I can find.
But if I remark this line out I don't get the error.
Call Hook(Me.Handle. ToInt32)
Which calls this function
Public Sub Hook(ByVal gHW As Integer)
lpPrevWndProc = SetWindowLong(g HW, GWL_WNDPROC, AddressOf WindowProc)
End Sub
That I had to delegate as below
Delegate Function WindowProcDeleg ate(ByVal hwnd As Integer, ByVal msg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
This is used in connection with a hotkey F10 to show and hide the desktop.
Norm
"Chris Dunaway" <du******@gmail .com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. . Norm wrote:
Thanks for the information, I am going to start over with a new blank
form and see how far I can get before seeing any errors. There is something
weird If you do get an error, print out the stack trace, which should provide more detailed information. You can use code similar to the follow to get the stack trace:
Try
'Code here that may generate an exception
Catch ex As Exception Dim s As String While Not ex Is Nothing s &= ex.Message & ": " & ex.StackTrace ex = ex.InnerExcepti on End While MsgBox(s) End Try
Hi
I think you may not need to use the subclass(ie call the SetWindowLong
API), you may try to take a look at the link below about how to handle the
keys in .NET.
Keyboard event handling in .NET applications by Alfred Mirzagitov http://thecoadletter.com/article/0,1410,30129,00.html
Also what is concrete job in winproc, did you do the aboutFrm.Show in the
F10 KeyDown?
Anyway I suggest you try the article above first, if that did not work,
please post/send your reproduce code.
e.g.
Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F10 Then
Dim fm As New Form2
fm.Show()
End If
End Sub
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Peter,
Trapping the key stroke from the form won't work for me, as the main form is
hidden and has an icon showing in the system task bar that shows a pop up
menu when clicked.
The program hides all the desktop icons, but allows you to use them through
the pop up menu.
I want to capture all keystrokes and when F10 is pressed to show the desktop
icons and when pressed again hide the desktop icons. I assume I will need to
do some type of message trapping, which is what I was doing with Hook and
WindowProc, which does not want to work with VB.Net.
Norm
""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:pr******** *****@TK2MSFTNG XA01.phx.gbl... Hi
I think you may not need to use the subclass(ie call the SetWindowLong API), you may try to take a look at the link below about how to handle the keys in .NET. Keyboard event handling in .NET applications by Alfred Mirzagitov http://thecoadletter.com/article/0,1410,30129,00.html
Also what is concrete job in winproc, did you do the aboutFrm.Show in the F10 KeyDown? Anyway I suggest you try the article above first, if that did not work, please post/send your reproduce code. e.g. Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown If e.KeyCode = Keys.F10 Then Dim fm As New Form2 fm.Show() End If End Sub
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no
rights.
I don't know if this was the best way, but I got it to work by Unhooking the
form while it was showing and then when it was hidden again calling the Hook
function.
Norm
"Norm" <No****@newsgro ups.nospam> wrote in message
news:ON******** ******@TK2MSFTN GP10.phx.gbl... Peter,
Trapping the key stroke from the form won't work for me, as the main form
is hidden and has an icon showing in the system task bar that shows a pop up menu when clicked.
The program hides all the desktop icons, but allows you to use them
through the pop up menu.
I want to capture all keystrokes and when F10 is pressed to show the
desktop icons and when pressed again hide the desktop icons. I assume I will need
to do some type of message trapping, which is what I was doing with Hook and WindowProc, which does not want to work with VB.Net.
Norm ""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message news:pr******** *****@TK2MSFTNG XA01.phx.gbl... Hi
I think you may not need to use the subclass(ie call the SetWindowLong API), you may try to take a look at the link below about how to handle
the keys in .NET. Keyboard event handling in .NET applications by Alfred Mirzagitov http://thecoadletter.com/article/0,1410,30129,00.html
Also what is concrete job in winproc, did you do the aboutFrm.Show in
the F10 KeyDown? Anyway I suggest you try the article above first, if that did not work, please post/send your reproduce code. e.g. Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown If e.KeyCode = Keys.F10 Then Dim fm As New Form2 fm.Show() End If End Sub
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matt |
last post by:
I want to submit the form to the server without opening another page.
When we do the following, it will submit the form data in myform to
the IIS, and open page2.asp.
<form name="myform" action="page2.asp" method="post">
But I don't want to open another page, I just want to submit the form data.
Should I do the following??
myform.submit();
|
by: Galina |
last post by:
Hello
I have a very complex database application, which have been working
fine for several years in Access 97. Now I had to convert it into
Access 2000.
The main form (course) has got 2 subforms. One subform (course
occurrence) has got 4 subforms of its own, another subform (course web
description) has got 1. The main form has got navigation buttons,
occurrence subform has got navigation buttons (there can be several
occurrences of the...
|
by: Thompson Yip |
last post by:
From time to time, I randomly receive "Can't updated, Currently
locked" error 3218 or 3246 from the following code in one of my form
with pessimistic lock for 70 users environment. Any problem with the
code?
Private Sub Save_Record_Click()
Dim stSQL As String
Dim rs As Object
Set rs = CreateObject("ADODB.Recordset")
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
|
by: Patrick Arkins |
last post by:
I have a Main form (named FRM_Main in the Forms Window) with a Subform
(named FRM_User_Search in the Forms window, form_User_Search on
Forms_Main).
FRM_User_Search has a combo-box (cboSort) the user will hopefully be
able to use to change the sort order of the records on the same form.
Here's the code for the "OnChange" event, minus the
DoCmd.Repaint.Object Line:
| |
by: salad |
last post by:
The 2455 error starts out with something like "You entered an expression
that has an invalid reference..." Going to Google the general
impression was that a reference was missing. At MS, there's not much
info on it. So...this is FYI in case you ever get this error. It may
not be the cause of it, but it could be also.
I had a form that opened another form and sometimes it'd open fine,
other times blow up. I couldn't easily see what...
|
by: Danny J. Lesandrini |
last post by:
How is it possible that VBA could ERR out on the same line 3 times in 5 seconds?
Below are the logs for two errors that happened one right after the other and you can
see that the same line is logged thrice for each function, each in a 5 second range.
Error is always #2486: You can't carry out this action at the present time.
ErrDateTime Line Function
7/31/2006 9:01:32 275 cmdOpen
7/31/2006 9:01:31 275 cmdOpen...
|
by: smiler2505 |
last post by:
I have a situation where there may be no table for a form; on error, the table is rebuilt and all is good; except to open the form, I have to click the form again. I tried
DoCmd.OpenForm "frmCSN"
but nothing happens. I think its because the form is already open, with the Sub form_OnError. But if I try and close the form, it crashes access and I get asked to send an error report, because the code is running from the form presumably. ...
|
by: DonRayner |
last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm getting the error before it opens.
The line of code that calls the form from another form is.
DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog
I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |