473,388 Members | 1,198 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Declaration expected

13
Hello
I'm getting the error "Declaration expected" twice in this code...
Expand|Select|Wrap|Line Numbers
  1. 'Required in all cases when calling API functions
  2. Imports System.Runtime.InteropServices
  3.  
  4. 'Required in this example and any API function which
  5. 'use a string buffer.  Provides the StringBuilder class
  6. Imports System.Text
  7.  
  8. Public Class Form1
  9.     <DllImport("KERNEL32.DLL", EntryPoint:="GetSystemDirectoryW", _
  10.          SetLastError:=True, CharSet:=CharSet.Unicode, _
  11.          ExactSpelling:=True, _
  12.          CallingConvention:=CallingConvention.StdCall)> _
  13.          Public Shared Function GetSystemDirectory(ByVal Buffer _
  14.            As StringBuilder, ByVal Size As Integer) As Long
  15.         ' Leave function empty - DLLImport attribute 
  16.         ' forces calls to GetSystemDirectory to
  17.         ' be forwarded to GetSystemDirectory in KERNEL32.DLL
  18.     End Function
  19.  
  20.     Public Const MAX_PATH As Integer = 256
  21.     'How to call the API function:
  22.  
  23.     Dim s As New StringBuilder(MAX_PATH)
  24.  
  25.         GetSystemDirectory(s, MAX_PATH)
  26.         msgbox(s.ToString(), , "System Directory")
  27.  
  28. End Class
  29.  
..it errors at GetSystemDirectory and msgbox
I thought it may need another imports statement, not sure
I'm using VB.net 2008 express
Aug 4 '10 #1
1 9242
PsychoCoder
465 Expert Mod 256MB
Well change MsgBox to use the MessageBox class (which is native to .Net). MsgBox is a legacy left over function from the VB6 (and older) days.

As for your other error, I copied your code word for word in an existing VB.NET project and it works fine for me, so I'll have to look further into this one
Aug 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ammar_ace | last post by:
Can Somebbody pls help me out here. i am new to .net programming, i am trying to connect to an access database and read, but i get the error message 'BC30188 Declaration Expected' this is what i...
5
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
9
by: D. Shane Fowlkes | last post by:
Still learning ASP.NET....(and I was getting so good with classic ASP too!). I'm trying to connect to a SQL Server using a simple connection script. I've checked 2 different books and looked at...
1
by: Chuck Insight | last post by:
Another newbie question. While working on a WEB project, I came across some code that looked promising, but retues an error. The code is: Private Sub Form_Load() The error it produced is: ...
3
by: rdi | last post by:
The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line...
3
by: Steve King | last post by:
I've an error in code I got from a walkthrough that should work just fine. I added a reference to DMO that shows up in the references properly. The Dim line shows no errors but the initialized...
2
by: phil | last post by:
Hi, When executing this (asp.net 2.0), i get the error: Compiler Error Message: BC30188: Declaration expected. Line 9: Dim dtreader As SqlDataReader Line 10: Line 11: db = new...
1
by: Cirene | last post by:
I'm binding a datagrid to my business object. I get an error that the type 'abcshoppingcart'...is not marked as serializable. So, I added a attribute in the class. But then a blue squiggly...
1
by: shekhardotnet | last post by:
below testing code gives an error "declaration expected" please suggest Imports System.Data.SqlClient Public Class Form1 Inherits System.Windows.Forms.Form 'Create ADO.NET objects....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.