?
Solved

Visual basic error

Posted on 2007-11-19
5
Medium Priority
?
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 1200 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 80 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 600 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 120 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

770 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