Solved

Visual basic error

Posted on 2007-11-19
5
181 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 52

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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