473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I can't see a functions between classes

Hi guys!

I got two classes, class1 and class2.

I'm trying to call a function defined in class1 from class2, but I get the
following error:

BC30451: Name 'WriteString' is not declared

How I can solve this issue?

Thanks a lot!
Nov 18 '05 #1
5 922
This is most likely a scope issue:

Is class1 in a namespace? If so ensure you fully qualify class1 with the
namespace like: mynamespace.class1

Are class 1 and class 2 in different assemblies? If so, make sure one is
referencing the other.

Is the method static? if not, make sure you have created an instance of the
object.

Does class 1 compile? If not, you won't be able to "see" it's method.

If none of these help can you post some sample code?

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi guys!

I got two classes, class1 and class2.

I'm trying to call a function defined in class1 from class2, but I get the
following error:

BC30451: Name 'WriteString' is not declared

How I can solve this issue?

Thanks a lot!

Nov 18 '05 #2
"Bryant Hankins" <bryanthankins@_NO_SPAM_hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
This is most likely a scope issue:

Is class1 in a namespace? If so ensure you fully qualify class1 with the
namespace like: mynamespace.class1

Are class 1 and class 2 in different assemblies? If so, make sure one is
referencing the other.

Is the method static? if not, make sure you have created an instance of the object.

Does class 1 compile? If not, you won't be able to "see" it's method.

If none of these help can you post some sample code?
Also, is the method (function) declared as Public? If not, is it both
declared Friend and are both classes in the same assembly?
--
John Saunders
johnwsaundersiii at hotmail

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi guys!

I got two classes, class1 and class2.

I'm trying to call a function defined in class1 from class2, but I get the following error:

BC30451: Name 'WriteString' is not declared

How I can solve this issue?

Thanks a lot!


Nov 18 '05 #3
The problem apperas when i call WriteString() function
Thanks

Imports System

Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
'---------- // CLASS : StringComponents
Public Class StringComponents
Inherits Page

'---------- // SUB : WriteString
Public Sub WriteString(SayItNow as String)
Response.Write(SayItNow)
End Sub

End Class

'---------- // CLASS : DataComponents
Public Class DataComponents
Inherits Page

'---------- // FUNCTION : OpenOleDbConnection
Public Function OpenOleDbConnection(ByVal MyConnection As
OleDbConnection, ByVal connString As String) As Boolean
Dim bReturn As Boolean
Try
If MyConnection.State <> ConnectionState.Open Then
With MyConnection
.ConnectionString = connString
.Open()
bReturn = True
End With
Else
WriteString("ERROR: Trying to open connection " &
MyConnection.Database.ToString & ". Connection is already open.")
bReturn = False
End If
Catch ex As Exception
WriteString(ex.Message & ex.StackTrace)
bReturn = False
Finally
OpenOleDbConnection = bReturn
End Try
End Function

'---------- // FUNCTION : CloseOleDbConnection
Public Function CloseOleDbConnection(ByVal MyConnection As
OleDbConnection) As Boolean
Dim bReturn As Boolean
Try
If MyConnection.State <> ConnectionState.Closed Then
With MyConnection
.Close()
.Dispose()
bReturn = True
End With
Else
WriteString("ERROR: Closing connection. Connection already
closed.")
bReturn = False
End If
Catch ex As Exception
WriteString(ex.Message & ex.StackTrace)
bReturn = False
Finally
CloseOleDbConnection = bReturn
End Try
End Function
End Class
"Bryant Hankins" <bryanthankins@_NO_SPAM_hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
This is most likely a scope issue:

Is class1 in a namespace? If so ensure you fully qualify class1 with the
namespace like: mynamespace.class1

Are class 1 and class 2 in different assemblies? If so, make sure one is
referencing the other.

Is the method static? if not, make sure you have created an instance of the object.

Does class 1 compile? If not, you won't be able to "see" it's method.

If none of these help can you post some sample code?

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi guys!

I got two classes, class1 and class2.

I'm trying to call a function defined in class1 from class2, but I get the following error:

BC30451: Name 'WriteString' is not declared

How I can solve this issue?

Thanks a lot!


Nov 18 '05 #4
You just need to create an instance of the class before you call it like so:
Dim com As StringComponents = New StringComponents
com.WriteString("TEST")

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
The problem apperas when i call WriteString() function
Thanks

Imports System

Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
'---------- // CLASS : StringComponents
Public Class StringComponents
Inherits Page

'---------- // SUB : WriteString
Public Sub WriteString(SayItNow as String)
Response.Write(SayItNow)
End Sub

End Class

'---------- // CLASS : DataComponents
Public Class DataComponents
Inherits Page

'---------- // FUNCTION : OpenOleDbConnection
Public Function OpenOleDbConnection(ByVal MyConnection As
OleDbConnection, ByVal connString As String) As Boolean
Dim bReturn As Boolean
Try
If MyConnection.State <> ConnectionState.Open Then
With MyConnection
.ConnectionString = connString
.Open()
bReturn = True
End With
Else
WriteString("ERROR: Trying to open connection " &
MyConnection.Database.ToString & ". Connection is already open.")
bReturn = False
End If
Catch ex As Exception
WriteString(ex.Message & ex.StackTrace)
bReturn = False
Finally
OpenOleDbConnection = bReturn
End Try
End Function

'---------- // FUNCTION : CloseOleDbConnection
Public Function CloseOleDbConnection(ByVal MyConnection As
OleDbConnection) As Boolean
Dim bReturn As Boolean
Try
If MyConnection.State <> ConnectionState.Closed Then
With MyConnection
.Close()
.Dispose()
bReturn = True
End With
Else
WriteString("ERROR: Closing connection. Connection already
closed.")
bReturn = False
End If
Catch ex As Exception
WriteString(ex.Message & ex.StackTrace)
bReturn = False
Finally
CloseOleDbConnection = bReturn
End Try
End Function
End Class
"Bryant Hankins" <bryanthankins@_NO_SPAM_hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
This is most likely a scope issue:

Is class1 in a namespace? If so ensure you fully qualify class1 with the
namespace like: mynamespace.class1

Are class 1 and class 2 in different assemblies? If so, make sure one is
referencing the other.

Is the method static? if not, make sure you have created an instance of

the
object.

Does class 1 compile? If not, you won't be able to "see" it's method.

If none of these help can you post some sample code?

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi guys!

I got two classes, class1 and class2.

I'm trying to call a function defined in class1 from class2, but I get the following error:

BC30451: Name 'WriteString' is not declared

How I can solve this issue?

Thanks a lot!



Nov 18 '05 #5
Thanks!

"Bryant Hankins" <bryanthankins@_NO_SPAM_hotmail.com> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
You just need to create an instance of the class before you call it like so:

Dim com As StringComponents = New StringComponents
com.WriteString("TEST")

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
The problem apperas when i call WriteString() function
Thanks

Imports System

Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
'---------- // CLASS : StringComponents
Public Class StringComponents
Inherits Page

'---------- // SUB : WriteString
Public Sub WriteString(SayItNow as String)
Response.Write(SayItNow)
End Sub

End Class

'---------- // CLASS : DataComponents
Public Class DataComponents
Inherits Page

'---------- // FUNCTION : OpenOleDbConnection
Public Function OpenOleDbConnection(ByVal MyConnection As
OleDbConnection, ByVal connString As String) As Boolean
Dim bReturn As Boolean
Try
If MyConnection.State <> ConnectionState.Open Then
With MyConnection
.ConnectionString = connString
.Open()
bReturn = True
End With
Else
WriteString("ERROR: Trying to open connection " &
MyConnection.Database.ToString & ". Connection is already open.")
bReturn = False
End If
Catch ex As Exception
WriteString(ex.Message & ex.StackTrace)
bReturn = False
Finally
OpenOleDbConnection = bReturn
End Try
End Function

'---------- // FUNCTION : CloseOleDbConnection
Public Function CloseOleDbConnection(ByVal MyConnection As
OleDbConnection) As Boolean
Dim bReturn As Boolean
Try
If MyConnection.State <> ConnectionState.Closed Then
With MyConnection
.Close()
.Dispose()
bReturn = True
End With
Else
WriteString("ERROR: Closing connection. Connection already closed.")
bReturn = False
End If
Catch ex As Exception
WriteString(ex.Message & ex.StackTrace)
bReturn = False
Finally
CloseOleDbConnection = bReturn
End Try
End Function
End Class
"Bryant Hankins" <bryanthankins@_NO_SPAM_hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
This is most likely a scope issue:

Is class1 in a namespace? If so ensure you fully qualify class1 with the namespace like: mynamespace.class1

Are class 1 and class 2 in different assemblies? If so, make sure one is referencing the other.

Is the method static? if not, make sure you have created an instance
of the
object.

Does class 1 compile? If not, you won't be able to "see" it's method.

If none of these help can you post some sample code?

--
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com

"Pepehammer" <pe********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
> Hi guys!
>
> I got two classes, class1 and class2.
>
> I'm trying to call a function defined in class1 from class2, but I
get the
> following error:
>
> BC30451: Name 'WriteString' is not declared
>
> How I can solve this issue?
>
> Thanks a lot!
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1620
by: Chris F Clark | last post by:
In our C++ project we have some internal bug reporting macros that we use to get useful information when the program does something unexpected. Essentially at the point of the error, we invoke an...
1
1016
by: Quentin Huo | last post by:
Hi: I have several classes and they have some same common functions like write a property value to a text file, or read from the file to a property. I did as followed: I created an abstract...
3
4175
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
13
1705
by: Simon Dean | last post by:
Hi, I have a couple of questions. If you don't mind. Sorry, I do get a bit wordy at times. First one just throws some thoughts around hoping for answers :-) 1) Anyone got a theory on the...
4
1182
by: Vj | last post by:
Hi all, I am contemplating a design wherein most functions in my base class are virtual and says "request_not_supported". My derived classes override only the functions they support. In net...
13
2271
by: Mark | last post by:
are there functions in c# for just members of a class myclass.Method/function Thanks Mark
3
2187
by: Juha Nieminen | last post by:
It occurred to me while developing an application: What happens if two (completely independent) base classes have the exact same virtual function, and then a derived class is derived from both,...
17
3510
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
23
2604
by: Chris Gordon-Smith | last post by:
Hello All I have a base class called Action_Request, and a set of classes corresponding to different kinds of Action_Request, each of which inherits from Action_Request. Eg:- class ...
17
8349
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
0
7128
marktang
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,...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
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...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
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...
0
5467
agi2029
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,...
1
4917
isladogs
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...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.