Simplest Issue

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

Is driving me nuts

In module 1....

Public pricing1 as String

Sub getPrice1
'do this to get price 1
price1 = "100"
MsgBox(price1)
End Sub

in the event procedure of the form

Sub getPricing
MsgBox(price1)
End Sub

The message box in the module produces the string.

The message box in the event procedure shows it is empty.

I also have noticed when I try to format a string not declared in a module
it says "object reference to a non shared member requires an object
reference."

I tried sharing the sub in teh module and it wont allow that.

Modules are all about sharing......

anyone have ideas?
 
ehh
Public pricing1 as String
MsgBox(price1)

have a look at the names

and try giving it a value
in your module :
Public price1 As New String("test")
 
The form procedure should read:

Sub GetPricing
getprice1
msgBox(price1)
End Sub

Sorry about that typing on the fly.
 
scorpion53061 said:
Is driving me nuts

In module 1....

Public pricing1 as String

Sub getPrice1
'do this to get price 1
price1 = "100"

price1 is not defined. Do you use Option Strict, or at least Option
Explicit?
MsgBox(price1)
End Sub

in the event procedure of the form

Sub getPricing
MsgBox(price1)
End Sub

The message box in the module produces the string.

The message box in the event procedure shows it is empty.

Resolved to the same variable? Right-click on variable name in the event
handler and select "go to definition". Same in the Msgbox line in the
module.
I also have noticed when I try to format a string not declared in a
module it says "object reference to a non shared member requires an
object reference."
Right.

I tried sharing the sub in teh module and it wont allow that.

Modules are all about sharing......

Yes, everything in a module is implicitly declared as shared.
 
Scor,

Not really sure how this will work unless you declare price1 at the module
level for instance

Module mystuff
Public price1 As String

Public Sub getPrice1
price1="100"
End Sub
End Module

In the from:

Public Class myFrom
Inherits System.Windows.Forms.Fom

Sub getPricing
mystuff.getPrice1() 'Note mystuff. is not necessary but adds to
readability
Msgbox(mystuff.price1)
End Sub
End Class
 
It should have said:

In module 1....

Public price1 as String

Sub getPrice1
'do this to get price 1
price1 = "100"
MsgBox(price1)
End Sub

in the event procedure of the form

Sub getPricing
getprice1
MsgBox(price1)
End Sub

The question is why the value shows in the message box of the sub in the
module but not in the message box of the form.

Armin and Solex the headers for your response came on my server but not the
text of your message. Please repost and thanks.
 
Here is the repost:

Scor,

Not really sure how this will work unless you declare price1 at the module
level for instance

Module mystuff
Public price1 As String

Public Sub getPrice1
price1="100"
End Sub
End Module

In the from:

Public Class myFrom
Inherits System.Windows.Forms.Fom

Sub getPricing
mystuff.getPrice1() 'Note mystuff. is not necessary but adds to
readability
Msgbox(mystuff.price1)
End Sub
End Class
 
Back
Top