|
Hey Hrizip,
Thanks for the detailed reply. I googled a bit and found that the bracketing means forcing VBscript to pass the array by value rather by reference.
And may I know which framework version you are using? We came across this post http://connect.microsoft.com/VisualStudio/feedback/details/331632/marshaler-bug-with-vbscript-arrays[^] and the guy commented that the problem (passing array from VBscript to .NET DLL thru COM) is only solved in .net framework 4.0.
Thanks!
The UI should look beautiful, so do the coding
|
|
|
|
|
|
It is difficult to say at this point which framework we were using at that point, chances are we were using 3.5.
We are still mostly using 3.5, only several machines have 4.0 installed.
Thanks for the info on double bracketing, I remember going through hell and trying every possible thing to make this work, I havent commited to memory all those trials (and errors).
Kinda not surprising that there is/was a bug in the framework itself, that would explain a great deal of things.
The whole process of interoping with legacy apps is just horrible, making it work gulps down 80% of total time spent developing an app.
Similar problems happen when you have to cross the managed/unmanaged barrier between apps, and between various C languages.
I remember going thru hell trying to adapt c++ code to vb.net code across managed/unmanaged barrier. It also has problems marshalling various data types, and its also "trial and error" until you find the right combination.
|
|
|
|
|
I have two label1 and label2 on form by default label2.visible=False. when mouse move on label1 then label2.visible=True, else if mouse is not on label1(or over any other control) then label2.visible=False
what should i do to set visibility of label2 to False if mouse is not over label1, help please
|
|
|
|
|
You can use the MouseEnter and MouseLeave events of Label1 and set Label2.Visible = False / True as appropriate.
|
|
|
|
|
there isn't any MouseEntry or MouseLeave events with label1 or 2.
i am using vb6
|
|
|
|
|
You should have mentioned you were using VB6 in your original post. If you don't, everyone assumes you're using VB.NET.
There is no equivilent event in VB6. The closeest you're going to get is MouseMove, but you cannot tell if the mouse has left the label control, only when the mouse is moving on the label control.
|
|
|
|
|
Well I didn't know that did I!
I don't have VB6 on any of my machines here at the moment, so can't look, but does the form have a MouseMove event? if so, you could use this in some way.
|
|
|
|
|
Tufail Ahmad wrote: there isn't any MouseEntry or MouseLeave events with label1 or 2.
There's a MouseMove that get's triggered when the mouse moves over the label - you could abuse that to simulate the events. Add a boolean value, and set it to "true" the first time that the MouseMove event fires. That would be the equivalent of a MouseEnter event.
Clear the boolean again when there's a MouseMove on the main form, or if you didn't receive a MouseMove in the last two seconds; that's your MouseLeave event
I are Troll
|
|
|
|
|
I have a project where I am converting a very complex MS Access front end to a VB.Net application. There are close to a hundred tables in a SQL database containing mostly but not completely static data that I plan on turning into individual classes.
So for each class I have a strongly typed dataset for per table, and a class. Each table has an ID (IDENTITY) field as a unique key. What I am wanting to do is have a generic way of populating and updating each of these classes. Here is what I have so far.
First I created a new Attribute class
<AttributeUsage(AttributeTargets.Property, Allowmultiple:=False, Inherited:=True)> _
Public Class DataTableSourceAttribute
Inherits System.Attribute
Private _dataTableField As String
Public Sub New(ByVal DataTableField As String)
_dataTableField = DataTableField
End Sub
Public Property DataTableField() As String
Get
Return _dataTableField
End Get
Set(ByVal Value As String)
_dataTableField = Value
End Set
End Property
End Class
Then in my class I use this to flag each property with the field that is associated with it in the database (the database is close to 10 years old and has no naming conventions whatsoever).
Imports System.Reflection
Public Class TransportMethod
Implements IEquatable(Of TransportMethod)
Private _code As String
Private _iD As Integer
Private _description As String
Private _requiresAttendant As Boolean
Public Sub New(ByVal row As dsTransportMethod.dtTransportMethodsRow)
ProcessRow(row)
End Sub
<DataTableSource("TransportMethod")> _
Public Property Code() As String
Get
Return _code
End Get
Protected Set(ByVal value As String)
_code = value
End Set
End Property
<DataTableSource("TransportMethodDesc")> _
Public Property Description() As String
Get
Return _description
End Get
Protected Set(ByVal value As String)
_description = value
End Set
End Property
<DataTableSource("TransportMethodID")> _
Public Property ID() As Integer
Get
Return _iD
End Get
Protected Set(ByVal value As Integer)
_iD = value
End Set
End Property
<DataTableSource("RequiresAttendant")> _
Public Property RequiresAttendant() As Boolean
Get
Return _requiresAttendant
End Get
Set(ByVal value As Boolean)
_requiresAttendant = value
End Set
End Property
Finally, here is the code to populate the class.
Private Sub ProcessRow(ByVal Row As dsTransportMethod.dtTransportMethodsRow)
Dim PropertyList As PropertyInfo() = CType(Me, Object).GetType.GetProperties(BindingFlags.DeclaredOnly Or BindingFlags.[Public] Or BindingFlags.Instance)
For Each objProperty As PropertyInfo In PropertyList
If objProperty.CanWrite Then
Dim oAttribs() As Attribute = CType(objProperty.GetCustomAttributes(GetType(DataTableSourceAttribute), True), Attribute())
If oAttribs.Length = 1 Then
Dim field As String = CType(oAttribs(0), DataTableSourceAttribute).DataTableField
CType(Me, Object).GetType.GetProperty(objProperty.Name).SetValue(Me, Row(field), Nothing)
Debug.Print(field)
End If
End If
Next
End Sub
End Class
My question (finally) is: Is there a simpler or better way to accomplish what I am trying to do? This will be a very long project, and I while I can add new functionality, I cannot break anything in the current system. I still need to write the generic code to persist the data back to the SQL DB.
Thanks.
|
|
|
|
|
If you are going to take the time to build new classes for each of your tables, then why are you trying to come up with a generic way of accessing the data ? You are willing to commit the time to create classes, so why don't you take advantage of .NET and write each class specifically for each table ? In the long run, won't you be better off ?
Research the topics of DAL (data access layer) and you will get a better idea of how to build an interface to your data.
This article has some really good points ...
Building an N-Tier Application in VB.NET, in 8 Steps[^]
Don't make things harder than they really are
Good luck.
|
|
|
|
|
Hi all,
I need to generate a check sum string from visual basic and pass to a Java implemented class according to the specification.
the requirement from user spec is saying that the check sum string should base on the following formula.
e.g. (Username + UserId + Transaction Amount + Transaction Date).
suppose I have the above parameters, but how can I generate the MD5 checksum string from VB?
can you provide an example? is it using Security.Cryptography.MD5CryptoServiceProvider ?
P.S. I need to genereate the checksum as a STRING.
thanks
|
|
|
|
|
See if this[^] helps.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
thanks for your reply, Abhinav
However, I'm not generate a checksum from a file stream.
firstly, i get a combination string from the parameters and by the formula I will get
string org_str = "JOHN_C2182_20102009"
I need a method to generate a checksum string from the above "org_str"
do you have other example?
thanks
|
|
|
|
|
|
There is an infinite number of definitions for "checksum". All that is basically required is the same data always returns the same checksum, so you could take an algorithm as simple as summing all of the individual bytes, up to wherever your imagination brings you. If MD5 is involved, you still have to decide how your original data would be presented to it, and how the resulting bytes would be converted to the output format your system wants.
Without a detailed description of the algorithm used on one side, you'll have a very hard time coming up with a matching implementation for the other side. Having one side implemented in either .NET or Java should allow you to peek into the code (using Reflector for .NET, JAD for Java) and create the same stuff again in e.g. VB.NET
If, not clear, you need VB, not VB.NET, then I don't know MD5 implementations are readily available.
modified on Wednesday, January 13, 2010 7:49 AM
|
|
|
|
|
Yes, Ok, I know this is a common problem, but I've read through a lot of similar threads and still can't seem to see what I'm doing wrong.
Some fresh eyes might see what is probably staring me in the face.
I've written the following sub to insert a record into an SqlCe database DataTable called BRDataTable.
On executing sqlInsert.ExecuteNonQuery() near the end of the code, I get an error message "There was an error in a part of the date format.".
I've put a breakpoint at sqlInsert.ExecuteNonQuery for debugging, and checked the contents of sqlInsert.CommandText , which is:
"INSERT INTO BRDataTable VALUES('Test', '13/01/2010', '', '', '1', '7', '0', '0')"
I've also tried setting CurrentRecord.WhenReady as DateTime instead of just Date, giving the following CommandText, but I still get the same error:
"INSERT INTO BRDataTable VALUES('Test', '13/01/2010 11:08:40 AM', '', '', '1', '7', '0', '0')"
I've double checked, and the DataType for the second column in the DataTable is definitely set to DateTime.
Thanks in advance.
Paul
Private Sub AddCurrentRecordToDatabase()
'#####################################################
'# Add the contents of CurrentRecord to the database #
'#####################################################
'Make a connection to the database
Dim sqlConn As New SqlCeConnection(sqlConnString)
'Set up the insert command
Dim sqlInsert As SqlCeCommand = sqlConn.CreateCommand
sqlInsert.CommandText = "INSERT INTO BRDataTable VALUES('" _
& CurrentRecord.Name & "', '" _
& CurrentRecord.WhenReady & "', '" _
& CurrentRecord.Address & "', '" _
& CurrentRecord.Notes & "', '" _
& ConvertBooleanToBit(CurrentRecord.Reminder) & "', '" _
& CurrentRecord.DaysWarning & "', '" _
& ConvertBooleanToBit(CurrentRecord.Acknowledged) & "', '" _
& CurrentRecord.Age & "')"
'Execute the insert command
sqlConn.Open()
sqlInsert.ExecuteNonQuery()
sqlConn.Close()
End Sub
|
|
|
|
|
Have you tried with date formatted mm/yy/dddd?
Just a thought...
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Thanks for your reply Andy_L_J.
I got it to work by formating the date as "yyyyMMdd"
|
|
|
|
|
Ok, I've got it working by formating the date component of my CommandText as "yyyyMMdd" , but I don't really understand why I had to do it this way.
Most of the threads I read regarding similar problems talked about formating the date as;
"MM/dd/yyyy"
or
"MM dd yyyy"
or
"MM.dd.yyyy"
or
"MM-dd-yyyy"
or
"dd/MM/yyyy"
etc etc
None of these worked though. Only "yyyyMMdd" worked.
This doesn't line up with my regonal settings either. We have the date format as "dd/MM/yyyy" here in Australia.
Can anyone give a good explanation why only "yyyyMMdd" works?
|
|
|
|
|
Paul Hasler wrote: Can anyone give a good explanation why only "yyyyMMdd" works?
yyyymmdd is the best date format in my books... it means all dates come out in date order when you return them in a query.
yyyymmdd is a standard to get around the horrors that we all have faced (I'm sure) back in the old days when someone would insert a date like "03/04/95", and depending on regional settings you would get 3 April 1995 or 4 March 1995.
|
|
|
|
|
Google for "vb.net parameterize query" and you'll find that, done without all the string concantentation, this would not have been a problem at all.
|
|
|
|
|
Thanks Dave! I Googled your suggestion and it was a bit of a revelation!
Someone needs to find the button marked PURGE on that "little black box with the flashing red light" that is the internet.
I've obviously only been mucking about with SqlCe for a week or so, and as a noob most of my searches for tutorials etc seem to have come up with the old dinosaur methods, so I assumed that's how it's done.
Parameterization is SO much cleaner and useable!
Cheers again.
Paul
|
|
|
|
|
This might be more of a framework issue, but since the code is VB....
We have a large application, written in VB.Net 3.5 and running on Vista systems using the Aero interface. During long processes, we show a form that displays continuing progress, like this:
Label1.Text = String.Format("Completed: {0}%", CInt((Count / Total) * 100))
Label1.Invalidate()
Me.Invalidate()
Application.DoEvents()
This works just fine, until the user turns to another task and a different window covers the progress form. At that moment, the form stops being updated. Moving the covering window away does not cause the form to start updating again, and the result is a useless box that taunts us, making us guess if it is almost done or stalled at 20%. A similar problem occurs with other forms of feedback such as progress bars and status controls.
Any suggestions?
|
|
|
|
|
TechBearSeattle wrote: Any suggestions?
yes. stop abusing DoEvents() and organize your app the proper way: GUI stuff in the main thread, everything that takes (or might take) more than 30 msec in one or more separate threads, possibly ThreadPool or BackgroundWorker; and all painting in paint handlers.
Here is some literature for you:
animation1[^]
crossthreads1[^]
|
|
|
|
|