|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Object Reference not set to an instance of an object
Hi,
I have a code that looks like this, and when it comes to MsgBoxStyle, i receive the message 'Object Conference not set to an instance of an object'. I need help as i am new to Visual Basic Code:
Private Sub frmMaintLessee_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Cursor = Cursors.WaitCursor
intmode = 1
LoadCityCombo()
LoadCountryCombo()
LoadLists()
ClearScreen()
Cursor = Cursors.Default
Exit Sub
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "LRDB - Lessee ")
Cursor = Cursors.Default
End Try
End Sub
LOADCITYCOMBO statement
Sub LoadCityCombo()
Try
objLessee.GetCityName()
'Populate city combo
Dim drcityname As DataRow
drcityname = objLessee.CityCombo.NewRow()
drcityname("cityname") = "<Select a City>"
objLessee.CityCombo.Rows.InsertAt(drcityname, 0)
'bind the data to the combo box
cboCity.DisplayMember = "Cityname"
cboCity.ValueMember = "Cityname"
cboCity.DataSource = objLessee.CityCombo
cboCity.ValueMember = "cityname"
Exit Sub
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
LOADCOUNTRYCOMBO
Sub LoadCountryCombo()
Try
objLessee.GetCountryName()
'Populate countryname combo
Dim drcountryname As DataRow
drcountryname = objLessee.CountryCombo.NewRow()
drcountryname("countryname") = "<Select a country>"
objLessee.CountryCombo.Rows.InsertAt(drcountryname , 0)
'bind the data to the combo box
cboCountryName.DisplayMember = "countryname"
cboCountryName.ValueMember = "countryname"
cboCountryName.DataSource = objLessee.CountryCombo
cboCountryName.ValueMember = "countryname"
Exit Sub
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
LOADLIST
Private Sub LoadLists()
Dim objLibrary As New clsLibrary
Dim strSQL As String
With objLibrary
strSQL = " SELECT top 100 dbo.tblMaintLesseeDetails.LesseeID, dbo.tblMaintLesseeDetails.LesseeName, dbo.tblMaintLesseeDetails.Address, dbo.tblMaintLesseeDetails.City, " _
& "dbo.tblMaintCountries.CountryName, dbo.tblMaintLesseeDetails.CountryCode, dbo.tblMaintLesseeDetails.Phone, dbo.tblMaintLesseeDetails.Fax " _
& "FROM dbo.tblMaintLesseeDetails INNER JOIN " _
& "dbo.tblMaintCountries ON dbo.tblMaintLesseeDetails.CountryCode = dbo.tblMaintCountries.CountryCode " _
& "ORDER BY LesseeId "
.LoadListView(Me.lsvLessee, strSQL, 8)
End With
End Sub
Last edited by Shadow Wizard : April 30th, 2008 at 09:40 AM. Reason: added [Code] and [/Code] tags around code please do that yourself next. |
|
#2
|
||||
|
||||
|
This looks like VB.NET code, not VB. Two different animals. Also please post only the relevant lines of code. The error message obviously points to a line somewhere.
__________________
Wolffy ------------------------ Teaching people to fish. |
|
#3
|
|||
|
|||
|
[QUOTE=Wolffy]This looks like VB.NET code, not VB. Two different animals. Also please post only the relevant lines of code. The error message obviously points to a line somewhere.[/QUOTE
The error msg is received at the following line. Private Sub frmMaintLessee_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try Cursor = Cursors.WaitCursor intmode = 1 LoadCityCombo() LoadCountryCombo() LoadLists() ClearScreen() Cursor = Cursors.Default Exit Sub Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "LRDB - Lessee ") Cursor = Cursors.Default End Try End Sub |
|
#4
|
||||
|
||||
|
--moved to the .NET forum.
read this to learn the correct syntax: http://www.programmersheaven.com/2/...Form-MessageBox also, when asked for "only the relevant lines of code" and you have an error, it means the one line that generates error. |
|
#5
|
||||
|
||||
|
Indeed, you're trying to use the VBScript flavor of MsgBox, not the VB.NET flavor. See the link above.
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > Object Reference not set to an instance of an object |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|