Public Const Question

.net , vb6 Brisbane, Australia
  • 18 years ago

    I need help
    How do i change the text/string in


    Code:
    Public Const WSKREMOTEHOST = "127.0.0.1"

    this is in 'modMain.bas'


    e.g.

    Code:
    WSKREMOTEHOST = "127.0.0.2"

    that doesn't work, a msgbox says:



    Compile error:


    Assignment to constant not permitted




    Please help


    as i need it


    Thanks in Advance


    Jonathon Rossi
    [[email protected]]

  • 18 years ago

    You cannot change a constant.....hence the term.


    If you want a variable you can change declare it as a public string


    public myvariable as string
    myvariable = "127.0.0.1"

  • 18 years ago

    in .NET its much easier and uses less code so you can declare a variable and assign a value all in one line:


    Public WSKREMOTEHOST as String = "127.0.0.1"


    Just thought I'd let you know

  • 18 years ago

    Thanks I haven't got vb.net so i will use the code above


    I am only new and I didn't think about that


    A constant is unchanginig, sorry for my dumbness


    Thanks again


    Jonathon Rossi

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” - Tom Cargill