|
you have to use the upgrading wizzard to convert the VB6 project to VB.NET and it will convert your .bas files to modules in VB.NET. When you are able to run your app under VB.NET you can convert it to C#. But why would you want to do that, you can have mixed languages in a solution.
Regards: Didi
|
|
|
|
|
They are only 2 *.bas files containing constants, structures and function declarations. Actually they are APIs (an old one), that asks me to add these two files in your vb6 project, in order to declare structure variables and call functions in it. But now i'm using .net. I'm looking if i can find any sample *.vbp file. Then i'll take your advice to upgrade it. With that i might get these 2*.bas files as 2 *.vb files. This would help me.
|
|
|
|
|
I thought, that you have a project, were the .bas files are part of it, then it would make sense to use the upgrade wizzard. If you only have to convert those files alone, and they are not too much code, I would try to copy paste the code into VB.NET and fix the errors, that are reported. That is probably faster.
Regards: Didi
|
|
|
|
|
I have finally created a .vbp file(looong story), added the two *.bas files in it, and upgraded it in VS2008. My
*.bas files were converted to *.vb files( ). But I got about 188 tasks to TODOs. After viewing them all I
found that there were only two types of warnings:
1.Fixed-length string size must fit in the buffer.
2.Structure may require marshaling attributes to be passed as
an argument in this Declare statement.
The first type of warning was fixed automatically during upgrade. The second type of warning was not
handled automaticaly.
So, to explain my question kindly see the details below:
The old VB6 code looks like this:
Type Struct1
str1 As String * 120
str2 As String * 120
str3 As String * 1024
End Type
\n
Declare Function MyFunction Lib "lib1.DLL" (pObject As Struct1) As Long
After upgrading VB.Net code looks like this:
Structure Struct1
'UPGRADE_WARNING: Fixed-Length string must fit in the buffer.
<VBFixedString(120),System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=120)>
Public str1() As Char
\n
'UPGRADE_WARNING: Fixed-Length string must fit in the buffer.
<VBFixedString(120),System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=120)>
Public str2() As Char
\n
'UPGRADE_WARNING: Fixed-Length string must fit in the buffer.
<VBFixedString(120),System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=1024)>
Public str3() As Char
End Structure
\n
'UPGRADE_WARNING: Structure Struct1 may require marshalling attributes to be passed
as an argument in this Declare statement.
Declare Function MyFuntion Lib "lib1.DLL" (ByRef pObject As Struct1) As Integer
So after reading the second warning my marshall attribute turns out to be like this:
<br />
<StructureLayout(LayoutKind.Sequential, CharSet:=CharSet.ANSI)><br />
Structure Struct1<br />
...<br />
End Structure<br />
My question is that:
Is the attribute written correctly for the structure?
Do I have to write this manually for all other structures?
Do I have to use this in the Declare statement as well? How?
Thanks a dozen Didi.
|
|
|
|
|
There is a difference between warnings and errors. Warnings are for you to know, that tere can be a potential problem, or to teach you someting, but errors occure when something goes wrong. So, I did not try actualy, but this should compile and run ok, because it has only warnings...
Good luck: Didi
|
|
|
|
|
Thanks a lot for the reply. Well this is the last issue and after that
I am done. I got 3 errors, and they were of the same type.
'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not suported.
Declare Function MyFunction2 Lib "myLib2" (ByVal arg As Any)<br />
As Integer
So can I use ByVal arg As Object instead of 'Any'?
Thanks again.
|
|
|
|
|
You should try to find out, what type the argument should be. See here[^] for reference. Good luck: Didi
|
|
|
|
|
I've got answers for everything(for now... ). Thanks a lot
|
|
|
|
|
I have an application written (VB6) a while ago and periodically updated. I keep old versions around simply by making a copy of the application source in a backup directory.
If I open the most recent version I find an error, Invalid use of Null (I know all about Nulls so lets not go down that path. Probably should have handled it better when it was originally written but when it was written we would not have had them, now we could)
If I open an older version of the program and run it, it does not give an error. This portion of code was last updated in 2003 or something and has not changed.
the offending line is
If UCase(rs!bin2File) = "CALLEDFROMDIAG" Then
in one version of code I get an error (current version), in the other (approx 6 months old) I do not
I know how to deal with it but am curious as to why it would behave differently...
any ideas?
|
|
|
|
|
If bin2file returns Nothing, you can't send it to UCase.
The code apparently doesn't check to see if rs is an actual recordset instead of Nothing.
It also doesn't check to see if a valid value is returned by rs!bin2File, instead of Nothing.
Try this and watch what happens: UCase(Nothing)
|
|
|
|
|
I understand what you are saying, but the question is why would it let me get away with it in a previous version of the program?
|
|
|
|
|
Because VB6 and VB.Net are totally different technologies and strings are handled differently since they are treated as immutable objects.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
|
I would check to see what's comming back from the database. If the app has hardcoded SQL in it, that may have changed in the new version, breaking the data that's coming back from the database.
|
|
|
|
|
Thanks, but it is indeed a null in both cases. Just an error in one and not the other
|
|
|
|
|
Null or Nullstring ""?
If UCase("" & rs!bin2File) = "CALLEDFROMDIAG" Then
|
|
|
|
|
I have set the max and min dates for the DateTimePicker.
When the program runs and the user tries to pick a date beyond the range, the computer "beeps".
Where/how can I put a msgbox() in there to indicate they are out of range?
I using VB.net 9
Thanks.
|
|
|
|
|
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged<br />
Dim Datebefore As Date<br />
Dim DateAfter As Date<br />
Dim DatePicked As Date<br />
<br />
Datebefore = ("01/01/2009")<br />
DateAfter = ("31/12/2009")<br />
<br />
DatePicked = DateTimePicker1.Value<br />
<br />
If DatePicked > DateAfter Or DatePicked < Datebefore Then<br />
MsgBox("Date Not Allowed", MsgBoxStyle.OkOnly)<br />
<br />
End If<br />
<br />
End Sub
Something like This?
Actually as I look at it I think you will need to put some kind of stop in there, I think it will loop, but I am sure you can manage that.
------------------------------------
"Possessions make you poor, wealth is measurable only in experience."
Sun Tzu 621BC
|
|
|
|
|
The DateTimePicker does not let the user pick a date before or after the MAX/MIN values I set in the DateTimePicker method. It responds with a "beep".
Therefor there is no value being reported back to the sub. Until a valid date is picked.
This code shows that.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DateTimePicker1.MaxDate = Today
DateTimePicker1.MinDate = "5/1/09"
End Sub
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
TextBox1.Text = DateTimePicker1.Value
End Sub
I know the system is reporting the attempt to pick a invalid date, because of the beep I hear.
So instead of just a beep, how can I get a MSGBOX()?
|
|
|
|
|
Have you done a Try/Catch as Exception?
------------------------------------
"Possessions make you poor, wealth is measurable only in experience."
Sun Tzu 621BC
|
|
|
|
|
There is no event that is raised by the control when an invalid date is attempted. Your code will never know that the user made such an attempt.
|
|
|
|
|
Thanks for the information.
|
|
|
|
|
I saw his code and thought it looked odd but couldn't see it!
My simple scribblings should be usable for him though, bending it to his needs of course, but I see the point about no event. But, if he is getting an Error Beep, is there no way to interupt at that point?
(Forgive my dimness, I am still learning )
------------------------------------
"Possessions make you poor, wealth is measurable only in experience."
Sun Tzu 621BC
|
|
|
|
|
How is your code going to know that it even happened?
|
|
|
|
|
I got you!
It only evaluates what has been picked AFTER it is selected, not whilst!
------------------------------------
"Possessions make you poor, wealth is measurable only in experience."
Sun Tzu 621BC
|
|
|
|