Solved

Visual basic error

Posted on 2007-11-19
5
175 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 49

Accepted Solution

by:
Ryan Chong earned 300 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now