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

migrating vb6 optional parameters

guy
found this oddity-
copying a vb6 function with optional parameters and pasting it into a vb2003
class, for conversion purposes, it all works fine except that the collapsing
"-" on the LHS goes away, only to return if "Optional" is removed. Strange.
anyone else had this?

guy

Dec 14 '05 #1
3 4077

guy wrote:
found this oddity-
copying a vb6 function with optional parameters and pasting it into a vb2003
class, for conversion purposes, it all works fine except that the collapsing
"-" on the LHS goes away, only to return if "Optional" is removed. Strange.
anyone else had this?


One thought: In VB6, you could just say "Optional param As type" and be
done with it, but in VB.NET "Optional parameters must specify a default
value" so if you just copy this valid in VB6) syntax into VB.NET:

Public Sub T(ByVal a As Integer, Optional ByVal g As Integer)

End Sub

you will get a squiggly line under the ), and no - collapsing section,
because it doesn't compile. Change it to eg

Public Sub T(ByVal a As Integer, Optional ByVal g As Integer = 0)

End Sub

and you get your - collapsing section.

--
Larry Lard
Replies to group please

Dec 14 '05 #2
"guy" <gu*@discussions.microsoft.com> schrieb:
copying a vb6 function with optional parameters and pasting it into a
vb2003
class, for conversion purposes, it all works fine except that the
collapsing
"-" on the LHS goes away, only to return if "Optional" is removed.
Strange.
anyone else had this?


The "+" isn't shown as long as there is a compile-time error in your method
declaration. I assume you forgot to assign a value to the optional
parameter, which will fix the problem:

\\\
Public Sub Foo(Optional ByVal Number As Integer = 0)
...
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 14 '05 #3
guy
Larry,Herfried, yes I thought that was the problem too but even with the
default in place no "-", however after removing the optional parameter
clicking on a different line and then replacing it it worked correctly.

guy

"Herfried K. Wagner [MVP]" wrote:
"guy" <gu*@discussions.microsoft.com> schrieb:
copying a vb6 function with optional parameters and pasting it into a
vb2003
class, for conversion purposes, it all works fine except that the
collapsing
"-" on the LHS goes away, only to return if "Optional" is removed.
Strange.
anyone else had this?


The "+" isn't shown as long as there is a compile-time error in your method
declaration. I assume you forgot to assign a value to the optional
parameter, which will fix the problem:

\\\
Public Sub Foo(Optional ByVal Number As Integer = 0)
...
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 14 '05 #4

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

Similar topics

13
by: William Ryan | last post by:
I just picked up a copy of John Robbins' debugging book and started to look at disassembled code. Anyway, I hate optional Parameters in VB, but I was checking them out to see what IL is created. ...
21
by: Marc DVer | last post by:
I am trying to create a query that can be loaded as a querydef object but not having to assign values to the parameters if I don't want to. Normally when using a parameter query in VBA my code...
16
by: ad | last post by:
Does C#2.0 support optional parameters like VB.NET: Function MyFunction(Optional ByVal isCenter As Boolean = False)
12
by: Nick Hounsome | last post by:
Can anyone tell me what the rational is for not supporting optional arguments. It is obviously a trivial thing to implement and, since C++ has them, I would not expect them to be omitted without...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
7
by: Sam Shrefler | last post by:
I'm working on creating a WebService / WebMethod to receive a record in real time from another system. The record contains about 20 fields. 10 of which aren't required. I was planning on just...
1
by: peridian | last post by:
This is more of a general question, but I didn't know where to post it. Since Java is an example of a language which does this, I thought here would work. Coming from a C++ background, having...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.