Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2007, 04:46 PM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't initialize variables

Hi Folks,

I'm using VB 2005 for web page development. I can't get an darn thing to compile in here. It's like upsidedown world. This compiles:

Code:
Imports Microsoft.VisualBasic

Public Class Class1
    Dim mystr As String = "bla"
End Class
whereas, this won't:

Code:
Imports Microsoft.VisualBasic

Public Class Class1
    Dim mystr As String = ""
    mystr = "bla"
End Class
Nor will:

Code:
Imports Microsoft.VisualBasic

Public Class Class1
    Dim mystr As String = "bla"
    mystr = "somethingelse"
End Class
They both give the same declaration expected error:
error BC30188: Declaration expected.

Please help me out of this dark land.
 
Old March 26th, 2007, 05:05 PM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops, looks like you can't do this outside a method.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to initialize arrays in c# apoorvchandra C# 2005 1 July 12th, 2008 08:35 PM
Initialize data in an HTML Control bnewton1 BOOK: Beginning Ruby on Rails 5 July 27th, 2007 05:24 PM
Need to be able to re-initialize a form kscase Visual Basic 2005 Basics 14 May 10th, 2007 09:54 AM
initialize variables junemo Pro PHP 2 July 15th, 2004 03:04 PM
initialize serial port miguel.ossa C++ Programming 0 February 13th, 2004 01:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.