|
I understood what you want to say.
Regards.
Samir R. Ibrahim
|
|
|
|
|
What has that to do with VB.Net?
SELECT @@IDENTITY returns the last inserted primary key.
|
|
|
|
|
I have an application in which i want to run multiple threads periodically.For this i am using the system.threading.timer in an array.
When i start the timer i also want to pass a string as a parameter to the timer callback method.There is a parameter; 'state as object'.Can i pass the the string through this?
For j As Integer = 0 To m_TimerList.Count - 1
'Dim oCallback As New TimerCallback(AddressOf timer1_tick)
Dim s As String = "1"
m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), New Object() {s}, 1, 5000)
k = k + 1
Next
How do i get the string in the timer callback method 'timer1_tick'
|
|
|
|
|
|
I am still not getting it...dont know how to adapt the example for my case.
Private Sub timer1_tick(ByVal state As Object)
Dim j As String = DirectCast(state, String)
End Sub
this gives an error.
|
|
|
|
|
Ok, what error, an invalid cast exception maybe? I don't programme in VB but I think the answer may be to pass s directly not as New Object() {s}.
m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), s, 1, 5000)
Alan.
|
|
|
|
|
thanks alot.that worked,
Dim s as string
m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), s, 1, 5000)
in the timer callback method...
Private Sub timer1_tick(ByVal state As Object)
Dim st As String = state
End Sub
NO casting...what is it used for anyway?
|
|
|
|
|
It is used for when you have Option Strict on (which you should turn on by default in the Options menu)
|
|
|
|
|
Glad the problem is sorted now. The compiler has done an implicit cast of Object to String but if you were to specify "Option Strict On" in your code you would have had to explicitly code the cast.
It's not a bad idea to code with strict on as it forces you to state your intentions more precisely, i.e. this parameter of type Object is actually a String and must not be anything else. The explicit cast does that for you.
Many implicit conversions will succeed and then you can be left with a major problem debugging difficult to comprehend logic errors in your code. Option Strict On will stop many of these errors before they happen and make your code more reliable.
Alan.
|
|
|
|
|
As I am in need to stop reading the barcode scanner,please give me the code to stop (disable ) and enable the serial port.
I expect the detailed code, since I am beginner in this area of VB.Net
-Noufi
|
|
|
|
|
I can't tell from your post whether you have written code to access the serial port.
If you haven't then read up on the System.IO.Ports namespace and come back with specific problems in your code.
If you just want general help on the serial port and example code then a quick search on Google will get you started.
Alan.
|
|
|
|
|
Noufe wrote: As I am in need to stop reading the barcode scanner,please give me the code to stop (disable ) and enable the serial port.
First, write you own code. You don't disable the serial port. You simply close the port your opened. This will keep you from reading any more data on the port until you open it again.
Noufe wrote: I expect the detailed code, since I am beginner in this area of VB.Net
You "EXPECT"? Ballsy, real ballsy. Don't start making demands in a forum environment. Epsecially since you're not paying for support and we all volunteer our time here.
|
|
|
|
|
I need to use one report with subreport i am using .Net Reporting.
The report is working without parameter from Master report to Sub Report
But when i pass the parameter to sub Report then it Give Error.
Is There Any Example or Tips Then Thanks
Best Regards,
Chetan Patel
|
|
|
|
|
Copy and paste your report to Bin/Debug Folder for the latest copy of the report because the application is running from that folder
Best Regards,
Chetan Patel
|
|
|
|
|
Hi all
I am comming from VFP environment, and I work most of my project in VFP in addition to some project in vb6 and now in vb.net
In VFP there is no OPTION EXPLICIT, which mean There is no Strongly Type variable available so can code something like
oIE = Createobject("InternetExplorer.Application"
cName = "Soemthing"
cName = 10
The small "c" is for Character, "o" for Object, "c" tells that the variable cName is character type variable.
Since in vb6 and vb.net are strongly Typed language, I have 2 question
#1 Is it best practice to use Variable Naming? or that is not important?
#2 if yes, what is the best Variable Name Technique?
TIA
Samir R. Ibrahim
|
|
|
|
|
Adding Prefix is good practice.
In .net It is best if you give proper name like
DateOfBirth instead of DOB
Initail Capital
And add First caracter for DataType means
dtDateOfBirth
Best Regards,
Chetan Patel
|
|
|
|
|
Chetan Patel wrote: Initail Capital
And add First caracter for DataType means
dtDateOfBirth
Hi Chetan.
That looks like a good way to follow.
Is there is a list for what prefix I should use for all kind of variables type?
Samir R. Ibrahim
|
|
|
|
|
Using a prefix to specify an aspect of a variable is called hungarian notation. It was originally intended for more important aspects than the variable type, but in a language where strict typing is not available it's quite useful to use it for the variable type.
In VB.NET you should not only use OPTION EXPLICIT ON, but also OPTION STRICT ON. That protects you from doing unintended implicit conversions, like assigning a string to an integer variable.
As you then have strict typing, there isn't really any need to use hungarian notation to keep track of the data types. Don't clutter up the variable names with information that's not really needed. If you use hungarian notation you should use it for something that it was intended for in the beginning, like separating validated (safe) data from unvalidated (unsafe) data.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
umm. that is
I got 2 answer,
one says it is good practice and I should use it. I agree with him regarding my previous usage to this hungarian notation in VFP.
and your answer which say no need to use it in OPTION EXPLIXIT ON and OPTION STRICT ON environment unless in special cases. and I TOTALLY Agree with you.
Since using it and not using is not very important as in VFP.
Is using it considered Best Practice? (Just yes/No)
TIA
Samir R. Ibrahim
|
|
|
|
|
Samir Ibrahim wrote: one says it is good practice and I should use it.
No, you shouldn't.
Samir Ibrahim wrote: Is using it considered Best Practice? (Just yes/No)
No. Not any more.
|
|
|
|
|
Thank you for the confirmation.
Samir R. Ibrahim
|
|
|
|
|
On the variable naming, it's a matter of preference really and if you can consistently get a group of devs to follow a standard. I've been in groups where everything is prefixed and in perfect Hungarian notation, and others where it was absolute chaos.
Any more if it's a project I'm doing solo, I use a 1 letter prefix on a value data types (Dim lCount as Long = 0L) and no prefix/notation with reference types; else I go with the flow and use whatever the standards are for the particular project/group.
Strict + Explicit = always ON.
My 2 cents... you ask 10 developers, expect 10 diff. answers - lol.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Jon_Boy wrote: On the variable naming, it's a matter of preference really
This is a golden sentence.
in vfp it is Best Practice. in vb6 or vb.net it is matter of preference
Jon_Boy wrote: My 2 cents... you ask 10 developers, expect 10 diff. answers - lol.
I will say if you ask 10 Developer, you will get 20 answer
I speak for my self when I am doing a large project is totally different from doing medium project and small project.
In large project I add my own prefixing to understand and quickly understand this variable, Public, Local, Private, where it came from (a form object, table, memory variable, reference, type, enum etc...
Where if you have lot of forms and lot of variable, and this variable should be public so the other variable in other form can take it is value.
end of line? in VFP I have 3 type of prefixing I follow.
In vb.net, I don't know yet if I will need that, since I am still in creating testing small projects (learning).
But from this thread (so far) I guess I will not.
Samir R. Ibrahim
|
|
|
|
|
Hi to All,
Here I come across a problem with CR.
When I run a specific query(joining two table) in MS access it works fine. But same query is repeating the resultant records twice. The query is as follows..
Dim qry1 As String = "SELECT distinct student.id, student.fname,student.lname, no_of_class_per_batch.no_of_class_held, student.no_of_class_att FROM (student INNER JOIN no_of_class_per_batch ON student.bid = no_of_class_per_batch.batch_id) where student.bid = '" & str & "'"
I am using vb.net2005 with Crystal Report.
Regards,
mahalakshmi
|
|
|
|
|
I am using Visual Basic 6.0 with MS Access in multiuser environment with DAO, I am trying to apply read lock on record, when the record is opened by another user, but not successful in doing so...Does any body know how this can be done what cursor type and lock type should be used for this purpose.
|
|
|
|