|
-
Apr 22nd, 2007, 11:08 PM
#1
Thread Starter
New Member
Problem with calling a module
Hi, I would like to know how to call a module in vb.net?
I received this warning : TypeInitializeException was unhandled. The type initializer for 'SAPWVA.basDetail' threw an exception.
Below is my code.... Can anyone pls tell me whats wrong with my code?
frmDetail :
Private Sub InitializeScreen()
With Me
gScrMode.Value = "INI"
.fraKey.Enabled = True
.lblStatus.Text = ""
.txtCustCode.Text = ""
...
..
.
Call basDetail.MenuControl(Me, 0, 0, 0, 0, 0, 0) ---warning shown at this line
.fraDetail.Enabled = True
.fraDetail.Visible = False
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
End With
End Sub
-------------------------------------------------------
basDetail :
Module basDetail
Dim GetDate As String
Dim StdRate As Decimal
Dim ctlMonth As Short
...
..
.
Dim vHexMth As New VB6.FixedLengthString("{0,-12}", "123456789ABC") 'YYH
'YYH -Amendment on Doc Ref, eg 0210 = 02A
Sub MenuControl(ByRef objForm As Object, ByRef V1 As Boolean, ByRef V2 As Boolean, ByRef V3 As Boolean, ByRef V4 As Boolean, ByRef V5 As Boolean, ByRef V6 As Boolean)
With objForm
.mnuCreate.Visible = V1
.mnuChange.Visible = V2
.mnuDelete.Visible = V3
.mnuSave.Visible = V4
.mnuCancel.Visible = V5
.mnuPrint.Visible = V6
End With
End Sub
----------------------------------------------
Ive tried several ways but the result is still the same. Below are what ive tried.
1) Changing ByRef to ByVal
2) Changing objForm as Object >>> objForm as frmDetail / System.Windows.Forms.Form / SAPWVA.frmDetail (SAPWVA is my project name)
3) Calling the module from Call basDetail.MenuControl(Me, 0, 0, 0, 0, 0, 0) >>> Call basDetail.MenuControl(Me, False, False, False, False, False, False)
-----------------------------------------------
I really have no idea of what's wrong with my code....and im stuck here.
Please help. This is kinda urgent.
Mant thanks.
-
Apr 22nd, 2007, 11:25 PM
#2
Re: Problem with calling a module
Is this code that was upgraded from a VB6 app? Here's another example of why rewriting code is a better idea than using the upgrade wizard. You should implement ALL those changes you mentioned for a start. Also, did you try removing the "Call" key word from the offending line?
-
Apr 22nd, 2007, 11:54 PM
#3
Thread Starter
New Member
Re: Problem with calling a module
Yes, the code is from a vb6 app and upgraded using upgrade wizard. Seriously, ive no experience in vb.net at all and thus, using the upgrade wizard was the best option for me. My dateline is approaching and i dont think i will have the time to rewrite the whole thing.
Well, ive tried removing call and what you mentioned but its still the same.
What should I do now?
Please help.
Many thanks.
-
Apr 23rd, 2007, 12:02 AM
#4
Re: Problem with calling a module
Unless your app is very simple the upgrade wizard can't complete without errors. To fix those errors you often need a better understanding of VB.NET than to write "proper" code in the first place, because of all the workarounds the upgrade wizard is forced to use. Basically, upgraded code is generally cr*p, as yours is.
That said, the error message says that the issue is in the type initialiser for the module. That would suggest to me that the problem is with one of the member variables. Try removing them one by one, or at least remove their initialisation, and see if and when the problem goes away. If you remove the initialisation for a variable and the problem goes away you've at least narrowed the problem to that variable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|