473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1977
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.D efault

"Al Reid" <ar*****@reidDA SHhome.com> wrote in message
news:e$******** ******@TK2MSFTN GP09.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*******@osla w.com> wrote in message news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..

"Al Reid" <ar*****@reidDA SHhome.com> wrote in message
news:e$******** ******@TK2MSFTN GP09.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.D efault


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******** *********@newsf e3-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
2510
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 unsigned char* buffer, size_t start_pos, size_t length) { char value = 0;
4
3611
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 of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and...
4
9254
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 a function and it gives me an option that I could write an extended stored procedure, but I don't have a clue of how to do it. To quickly fix the...
2
15857
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 MB, you get the picture. Both the GB and MB assorted values exist in both columns. Is there anyway to convert the GB or MB to 0's, or even...
2
18479
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? What is the way you guys are checking for nulls on string parms and triming if they pass something other then null. I was thinking this would do...
17
4350
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 problem writing VB Double values to the file so as the Pascal program can read them as Pascal Real values. I've managed to find the algorithm to...
7
29191
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
1407
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 declaration statments (first lines) e.g. Public Function ConvertCurrencyToEnglish(ByVal MyNumber As Double) As String Private Function...
4
4511
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 it seems this convert is determined by the local settings and comma is indeed used as decimal separator. Is there another way to convert a dotted...
4
118787
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 character into a number?????? In Oracle, it is:
0
7659
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7945
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5481
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.