Solved

Visual basic error

Posted on 2007-11-19
5
178 Views
Last Modified: 2013-11-27
What is the error in this code?

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Private strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ "C:\Documents and Settings\reid\Desktop\BSN Home.mdb;"

I get an identifier message about the underscore next to the ampersand above - what shouod I change it to?
       
0
Comment
Question by:Dier02
5 Comments
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 300 total points
ID: 20311166
try:

Private strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\reid\Desktop\BSN Home.mdb;"
0
 

Assisted Solution

by:Encognito
Encognito earned 20 total points
ID: 20311210
you may be able to change & to + if thats the problem
0
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 150 total points
ID: 20311541
ryancys' correct. The underscore is used when splitting code over multiple lines. If all the code is on the one line, the underscroe is not needed.

Wayne
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 30 total points
ID: 20311542
Private strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Documents and Settings\reid\Desktop\BSN Home.mdb;"
0
 
LVL 2

Expert Comment

by:andrewneely
ID: 20319331
try using dim instead of private inside subproceedures.  Private can be used at the class, form or module levels, but not at the subroutine level
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question