Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3750522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T08:56:46+00:00 2026-05-19T08:56:46+00:00

First of all thanking everyone…. I am currently working on VB. I am using

  • 0

First of all thanking everyone….

I am currently working on VB. I am using Visual Studio 2008.

The piece of code below is a console application which builds without any error.

    Imports System.Net


Module Module1

    Public Sub Main()

        Dim address As IPAddress
        Dim remoteIP As System.Net.IPEndPoint
        Dim socketAddress As System.Net.SocketAddress

        Try
            address = IPAddress.Parse("192.168.0.187")
            remoteIP = New System.Net.IPEndPoint(address, 0)

            socketAddress = remoteIP.Serialize()

            Console.WriteLine("Address Family :" & remoteIP.AddressFamily.ToString())
            Console.WriteLine("IP :" & remoteIP.Address.ToString() & "Port :" & remoteIP.Port.ToString())
            Console.WriteLine("Socket address :" & socketAddress.ToString())


        Catch ex As Exception
            Console.WriteLine(ex.StackTrace.ToString())


        End Try

    End Sub


End Module

In the next program which is a dll the same gives error saying “Declaration Expected for addr, remoteIP and socketAddr”

Imports System.Net

Public Class Class1


End Class
Public Class ethernet

    Dim addr As IPAddress
    Dim remoteIP As System.Net.IPEndPoint
    Dim socketAddr As System.Net.SocketAddress

    addr = IPAddress.Parse("192.168.0.187")
    remoteIP = New System.Net.IPEndPoint(addr,0)

    socketAddr = remoteIP.Serialize()



End Class

Can anybody tell me why is this happening…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T08:56:46+00:00Added an answer on May 19, 2026 at 8:56 am

    Your code in the second class ethernet is not contained within a Method, therefore you are only declaring the addr, remoteIP and socketAddr variables.

    To make that work just put the code in a method, like:

    Public Class ethernet
        Public Function SerializeSocket(address As String) As System.Net.SocketAddress
            Dim addr As IPAddress = IPAddress.Parse("192.168.0.187")
            Dim remoteIP As System.Net.IPEndPoint = New System.Net.IPEndPoint(addr,0)
            Return remoteIP.Serialize()
        End Sub
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using Visual Studio 2010, but this was first conceived with VS2003. I
I have few questions. First of all does code below violates law of Demeter?
First of all Merry Christmas to everyone!!! Currently I have a NSArray that has
First of all, i would like to explain my condition right now. I'm using
I have a strange dilemma.... First of all, I am stuck using XPath 1.0
First let me start by thanking you all for being part of this site,
First of all, I love vim. I have been using vim for a few
First of all, I am using PhpMyAdmin , is this okay or not? Because
First of all, I do not have any code written yet, I am only
First of all, I'm using MVVM for this and I would like to continue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.