473,385 Members | 1,320 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,385 software developers and data experts.

Convert Function to VB.NET

I have a simple function that I use in many of my applications. It allows one to update the "Status" panel of a status bar and
optionally set the MousePointer. This is useful if the status is being changed to "Processing" and you want to show the Wait
cursor.

Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer As Long = -1)

sbrMain.Panels("Status") = Status

If Pointer <> -1 Then
Me.MousePointer = Pointer
End If

Me.Refresh

End Sub
This doesn't seem to convert properly using the Upgrade Wizard and I can't seem to find a proper conversion. I tried:

Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer As Cursor = Cursors.No)

But is says that the Optional parameter requires a constant Expression. It seems that Cursors is a class and that No is a property.

Any suggestions?

--

Al Reid
Nov 21 '05 #1
4 1973
The windows forms has a status bar control you should check out:
System.Windows.Forms.StatusBar

You can change the cursor as follows:
Cursor.Current = System.Windows.Forms.Cursors.Default

"Al Reid" <ar*****@reidDASHhome.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
I have a simple function that I use in many of my applications. It allows
one to update the "Status" panel of a status bar and
optionally set the MousePointer. This is useful if the status is being
changed to "Processing" and you want to show the Wait
cursor.

Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer
As Long = -1)

sbrMain.Panels("Status") = Status

If Pointer <> -1 Then
Me.MousePointer = Pointer
End If

Me.Refresh

End Sub
This doesn't seem to convert properly using the Upgrade Wizard and I can't
seem to find a proper conversion. I tried:

Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer
As Cursor = Cursors.No)

But is says that the Optional parameter requires a constant Expression.
It seems that Cursors is a class and that No is a property.

Any suggestions?

--

Al Reid

Nov 21 '05 #2
"H. Williams" <hw*******@oslaw.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...

"Al Reid" <ar*****@reidDASHhome.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
I have a simple function that I use in many of my applications. It allows
one to update the "Status" panel of a status bar and
optionally set the MousePointer. This is useful if the status is being
changed to "Processing" and you want to show the Wait
cursor.

Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer
As Long = -1)

sbrMain.Panels("Status") = Status

If Pointer <> -1 Then
Me.MousePointer = Pointer
End If

Me.Refresh

End Sub
This doesn't seem to convert properly using the Upgrade Wizard and I can't
seem to find a proper conversion. I tried:

Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer
As Cursor = Cursors.No)

But is says that the Optional parameter requires a constant Expression.
It seems that Cursors is a class and that No is a property.

Any suggestions?

--

Al Reid

The windows forms has a status bar control you should check out:
System.Windows.Forms.StatusBar

You can change the cursor as follows:
Cursor.Current = System.Windows.Forms.Cursors.Default


I know how to change the cursor. My question is how to correct the Function so that I don't need to rewrite all of the code that
calls this.
Can this be fixed or do I have to scrap it and start over?

Surely there must be a way to pass a mouse pointer to a function w/optional parameters.

--
Al Reid
Nov 21 '05 #3
Al Reid wrote:
But is says that the Optional parameter requires a constant
Expression. It seems that Cursors is a class and that No is a
property.


The problem here is that Cursor.No is an object, and you can't use an object
as the default value for an optional parameter.

Here are two suggestions to work around this:

1. Use Nothing as the default value:

\\\
Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer As
Cursor = Nothing)
sbrMain.Panels("Status") = Status
If Not Pointer Is Nothing Then
Me.MousePointer = Pointer
End If
Me.Refresh
End Sub
///
2. Use overloaded procedures to obtain the same effect:

\\\
Public Overloads Sub UpdateStatusBar(ByVal Status As String)
sbrMain.Panels("Status") = Status
Me.Refresh
End Sub

Public Overloads Sub UpdateStatusBar(ByVal Status As String, ByVal Pointer
As Cursor)
'Delegate to other overload instance to do the statusbar work
UpdateStatusBar(Status)
'Now set the pointer
Me.MousePointer = Pointer
End Sub
///
Either of these should get you going without having to change lots of code.

Hope that helps,

--

(O) e n o n e
Nov 21 '05 #4
Thank you. Using Nothing as the default solved the problem

--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain

"Oenone" <oe****@nowhere.com> wrote in message news:Jz*****************@newsfe3-win.ntli.net...
Al Reid wrote:
But is says that the Optional parameter requires a constant
Expression. It seems that Cursors is a class and that No is a
property.


The problem here is that Cursor.No is an object, and you can't use an object
as the default value for an optional parameter.

Here are two suggestions to work around this:

1. Use Nothing as the default value:

\\\
Public Sub UpdateStatusBar(ByVal Status As String, Optional ByVal Pointer As
Cursor = Nothing)
sbrMain.Panels("Status") = Status
If Not Pointer Is Nothing Then
Me.MousePointer = Pointer
End If
Me.Refresh
End Sub
///
2. Use overloaded procedures to obtain the same effect:

\\\
Public Overloads Sub UpdateStatusBar(ByVal Status As String)
sbrMain.Panels("Status") = Status
Me.Refresh
End Sub

Public Overloads Sub UpdateStatusBar(ByVal Status As String, ByVal Pointer
As Cursor)
'Delegate to other overload instance to do the statusbar work
UpdateStatusBar(Status)
'Now set the pointer
Me.MousePointer = Pointer
End Sub
///
Either of these should get you going without having to change lots of code.

Hope that helps,

--

(O) e n o n e

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sam Smith | last post by:
Hi, I wan't a function to take a const char*, a start bit position and number of bits and convert that bit-stream into a primitive of desired type. I.e. something like: char convert(const...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
4
by: Rodusa | last post by:
I am having problem to apply updates into this function below. I tried using cursor for updates, etc. but no success. Sql server keeps telling me that I cannot execute insert or update from inside...
2
by: Bubba | last post by:
I know it's possible, just don't know how to do it. I have a spreadsheet that I imported into access. Two of the columns in the table have Hard Drive space values listed for example 2.45 GB and 453...
2
by: William Stacey | last post by:
Example line: string temp = Convert.ToString(null); Convert.ToString() says it will return empty string if null is passed as parm. This returns a null. Is this oversight in the Convert method?...
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
4
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.