|
hi, i have a windows application. in load event of my form i retrieve data from " Microsoft Access" database.
when i build or run form,i see several Error MessageBox with this content : "object reference not set to an instance of an object ".
after that i submit these,Program Runs Successfully!!
what is my problem?
thanks
|
|
|
|
|
Your main problem appears to be that you can't decide what account to post with, or what language you're using. Or did a different user just happen to post the exact same question in the C# forum ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Dear Christian Graus
I am programmer with both C# and VB
It happened many times ,i Asked my problem in both C# and VB forums and i accept my answer in only one of theme.
Thanks
|
|
|
|
|
That message means you tried to set a property or call a method on a class that wasn't instantiated. The most common cause is that you assumed you'd get back an object from some kind of query, but instead, you got back Nothing and tried to use it or make some modification to it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you MR Dave Kreskowiak
|
|
|
|
|
Hi,
I have created 2 simple projects, one executable and one dll. The exe has a reference to the dll.
When I try to compile the dll (TEST TWO.vbproj) from a batch file the exe (TEST ONE.vbproj) is compiled also. Why does this happen? I thought I would have to issue another command to build the exe.
The batch file I use looks like
<br />
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0" /v InstallDir') DO SET InstallDir=%%B<br />
<br />
set mycommand="%InstallDir%devenv" /build Release /out "C:\BuildErrors.log" ".\TEST TWO\TEST TWO.vbproj"<br />
echo %mycommand%<br />
<br />
@call %mycommand%<br />
<br />
pause<br />
If anyone can suggest a nicer way of finding out the Visual Studio installation path I'd be very grateful.
Thanks very much,
dlarkin77
|
|
|
|
|
Have you considered using MSBUILD instead of using the Visual Studio environment? As I understand it, visual studio just uses MSBUILD underneath the covers anyway.
It can be accessed from the following path:
%windir%\Microsoft.NET\Framework\v2.0.50727
|
|
|
|
|
Thanks for that info Colin. I started looking at MSBuild but I got totally sidetracked with NAnt.
I've been playing around with it and it looks pretty good. But whenever I try to build a Windows Forms application the XP Visual Styles are being lost. Can anyone tell me what I need to do to keep the xp styles?
The build file I use is below:
<code>
<?xml version="1.0" encoding="Windows-1252" ?>
<project name="TESTER" default="run" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
<property name="basename" value="TESTER"/>
<property name="debug" value="true"/>
<property name="build.dir" value="bin"/>
<namespaceimports id="tester.imports">
<import namespace="Microsoft.VisualBasic" />
<import namespace="System" />
<import namespace="System.Collections" />
<import namespace="System.Data" />
<import namespace="System.Diagnostics" />
<import namespace="System.Drawing" />
<import namespace="System.Windows.Forms" />
</namespaceimports>
<target name="build">
<mkdir dir="${build.dir}"/>
<vbc target="winexe" output="${build.dir}/${basename}.exe" debug="${debug}"
main="TESTER.frmMain"
optioncompare="text"
optionexplicit="true"
optionstrict="true"
rootnamespace="TESTER"
removeintchecks="true">
<imports refid="tester.imports" />
<sources>
<include name="*.vb" />
</sources>
<references>
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Drawing.dll" />
<include name="System.Windows.Forms.dll" />
<include name="System.Xml.dll" />
</references>
</vbc>
</target>
<target name="run" depends="build">
<exec program="${basename}.exe" basedir="${build.dir}" />
</target>
</project>
</code>
Thanks very much,
dlarkin77
|
|
|
|
|
What is the simplest way to update or add data with a DataSet?
My Dataset contains various tables with relations, I want a way to update my datasource according to all the changes that has taken place on my dataset (changes made by means of data-bound controls).
As far as I now System.Data.DataSet.AcceptChanges() does this, updating both the DataTables' and the DataRows' data to the datasource.
My problem is that when I add a control (eg. TextBox) to my form and setup it's DataBinding, it doesn't seem to communicate with the DataSet, so when I type something in that field and execute AcceptChanges() it doesn't update my datasource.
The control's databinding is setup to a BindingSource which has my dataSet as Source.
What does work is to do a BindingSource.EndEdit() for a specific DataTable and then a TableAdapter.Update() but this seems to update the datasource as well and totally bypasses the "global update" functionality I hope to obtain by using the Dataset.AcceptChanges() method.
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
note on virtual execution system
thank you
|
|
|
|
|
Was that meant to be a question ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
What are you talking about? Are you asking about "virtual machines"?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Sir/Madam,
I am creating the table programically .In the query like
dim sql as string = "create table tablename(field1,text)
After creating the table.I am getting the Memo Field instead of text.all i want is field1 should have text type with some length.But i am getting memo type of field1 in table.
Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
Hi Pankaj,
If I understand you correctly, you are either getting what you want, or you are using the wrong type. In some databases text = memo, in a sense it is type NVARCHAR, but with the maximum length for such a field. If you want to create a field that can contain text of a certain length, you should use:
create table tablename(field1, NVARCHAR(x))
where x is some number.
I hope that answers your question,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
|
Sir/Madam,
I wanted to know the difference between integer and int32 .Basically in which situations we should use integer and in which situations we should use int32.
Thanks and regards
Pankaj Garg
|
|
|
|
|
Please don't ask twice.
Your question has nothing to do with intptr. There are no situations I can think of where I'd use one over the other, in fact, I use int all the time, I'm not sure they are different ( unless int is not 32 bit, but I assume it is )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sir/Madam,
I am sorry .Actually by mistake the title of the problem is written wrong.Next time i will take care of it.
Thanks and Regards
Pankaj
|
|
|
|
|
There is no difference between Integer and Int32. Integer is the VB.Net alias for a System.Int32, a 32-bit signed integer.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
It is best to only use types such as int32, int16 etc. when you need to guarentee a certain number of bits are used to store a value (whether that be numerical, bit flags, or just encoded data of a proprietory type).
If you generally dont care how many bits it takes to store the value use a basic type, such as integer, long etc.
The general purpose, from my point of view, for types such as int32 is to ensure portability of code across several platforms (as I mention above e.g. -- if you are using the bits in a variable to flag information you may need to ensure you have a minimum of 32 bits -- using a basic type like integer does not mean you will necessarily have a 32bit variable, although in the case of .Net this is actually true).
Regards,
Martin
|
|
|
|
|
Sir/Madam,
I want to know the meaning of Intptr.
Dim a as Intptr.
I mean to say that What is the utility of intptr.
Thanks and Regards
Pankaj Garg
|
|
|
|
|
An intptr is a pointer. It's the type used to pass pointers where needed, such as a windows handle.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
'this is the module as followings:
Option Explicit
Declare Function lineGetCountry Lib "tapi32.dll" (ByVal dwCountryID As Long, ByVal dwAPIVersion As Long, ByRef lpLineCountryList As LINECOUNTRYLIST) As Long
Global Const TAPI_VERSION_MIN = &H10003
Global Const TAPI_VERSION_MAX = &H20001
Public Const LINEERR_INVALCOUNTRYCODE = &H80000022
Public Const LINEERR_INCOMPATIBLEAPIVERSION = &H8000000C
Public Const LINEERR_INVALPOINTER = &H80000035
Global grt As LINECOUNTRYLIST
Global GRT1 As LINECOUNTRYENTRY
Type LINECOUNTRYLIST
dwTotalSize As Long
dwNeededSize As Long
dwUsedSize As Long
dwNumCountries As Long
dwCountryListSize As Long
dwCountryListOffset As Long
End Type
Type LINECOUNTRYENTRY
dwCountryID As Long
dwCountryCode As Long
dwNextCountryID As Long
dwCountryNameSize As Long
dwCountryNameOffset As Long
dwSameAreaRuleSize As Long
dwSameAreaRuleOffset As Long
dwLongDistanceRuleSize As Long
dwLongDistanceRuleOffset As Long
dwInternationalRuleSize As Long
dwInternationalRuleOffset As Long
End Type
'this is the code in the form as following
Private Sub Form_Load()
Dim rt As Long
grt.dwTotalSize = Len(grt)
grt.dwCountryListSize = Len(grt)
'GRT1.dwCountryNameSize = Len(grt)
rt = lineGetCountry(1, TAPI_VERSION_MAX, grt)
Select Case rt
Case LINEERR_INVALCOUNTRYCODE
Text1.Text = " LINEERR_ALLOCATED"
Case LINEERR_INCOMPATIBLEAPIVERSION
Text1.Text = "LINEERR_INCOMPATIBLEAPIVERSION"
Case LINEERR_INVALPOINTER
Text1.Text = "LINEERR_INVALPOINTER"
Case Else
Text1.Text = rt
End Select
Text2.Text = grt.dwNumCountries
Text4.Text = GRT1.dwNextCountryID
Text3.Text = grt.dwCountryListOffset
End Sub
thanks
|
|
|
|
|
First, keep this with the original post thread. Don't start a new one.
Second, this is the VB6 code you're trying to convert, not the VB.NET code you've tried. But, change all the Long 's to Integer . Long in VB.NET is a 64-bit signed integer, but under VB6, it was only 32-bits. This is the most common mistake when converting VB6 code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi all,
New to programing so forgive the basic question.
I have created an app with a form that should fill the screen when loaded (its a big 1 screen app by requirement). I am using a 1280 x 1024 screen and I noticed that when I load it on a friends screen that the form window over fills the screen.
I guess this is something to do with the different aspect ratios or something.
Is there a way that I can make my app window dynamically shrink without lossing any info on the screen- I've tried anchoring the controls and locking them etc but when the parent form is resized they just get cut up.
any help or a point in the right direction would be very much appreciated.
|
|
|
|