|
Well, if you have a constant stream then DataReceived probably won't help because there will always be something to read. If you have a constant stream of data to read and parse, I'm not sure what else you can do except throttle back the rate at which you're reading it.
I suppose you could sleep the thread for a few milliseconds before reading from the port if you don't find a header. I don't know the exact requirements for your application, but would it really be that big a deal if there was a 10 millisecond delay before a message header was processed? Actually, even if you specify Sleep(0) immediately before the read it might help because it will yield the thread and give other threads a chance to cut in and do some processing. It's a bit clunky but it would reduce the amount of CPU time the thread is using.
|
|
|
|
|
sorry I'm not reading your code unless you edit it and put it in PRE tags, resulting in proper coloring and indentation.
[ADDED] you should not have polling loops without delays, so when no data is available, waste some time by calling Thread.Sleep(30); or use events. And watch for incomplete packets! [/ADDED]
modified on Monday, December 7, 2009 7:31 AM
|
|
|
|
|
honestly if that's how you feel, then don't read it, simple, I really don't need to know u don't want to read my code, thanks for letting me know tho...its in CODE tags at the moment but i'll change it to PRE...
to be honest I diddn't realise it diddn't indent as I don't post on here too often...a simple "hey, try using the PRE tags instead of CODE tags and your code should indent properly and will be easier for people to read" wouldn't really be be so hard would it? its probably even less characters to type...
|
|
|
|
|
the fix is simple, and much shorter than your above message. However I'm not sure you are really interested, as you downvoted my previous message. Making code readable is the first step to solving problems, and me asking and you adding PRE tags did help. I think I'll wait for you to change your vote.
|
|
|
|
|
Luc Pattyn wrote: as you downvoted my previous message
I balanced it.
Best wishes,
Navaneeth
|
|
|
|
|
|
I need to know how to be able to type a quotation mark into a text box in Visual Basic 2008.
like so...
TextBox1.Text = "[a href=""]LINK[/a]"
Had to substitute the < and > for [ and ].
That is a bad example, because I've already gotten that to work for me... but like how to get the Quotes after the href= to show up in the textbox.
|
|
|
|
|
You already did it. VB.NET uses two double-quote marks to escape one. So, this:
TextBox1.Text = "<a href="""">LINK</a>"
will show this in the textbox:
<a href="">LINK</a>
|
|
|
|
|
I have two form :
class form1 'parent form
dim number as integer
public sub create ()
dim f2 as new form2
f2.MdiParent = me
f2.show()
end sub
public sub test()
end sub
endclass
In form2.vb how to use variable number and method test
thank you very much
Regards
|
|
|
|
|
If "test" is an event handler, you should be using a delegate to handle the event in other forms. If it a method that provides some common functionality, it should be placed in a separate class file, something like "Common.vb" and should be placed there. There you can have it as an internal static or an internal method to call it in any of the forms in your application.
You can make the method internal in the MDI parent itself and access it in the child using Me.MDIParent property.
To access the variable number, you can make use of a internal/public property and can access it using me.MDIParent again.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
In Form1:
Public number As Integer
In Form2:
Form1.Test()
Debug.Writeline(Form1.number.ToString)
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
|
This is a graduation project and you're asking us for the code to solve a problem?? You don't really deserve to graduate then, do you?
If you can't dig around in your brain and write the code yourself, what good is your degree then?
|
|
|
|
|
Dave Kreskowiak wrote: a graduation project and you're asking us for the code to solve a problem?
Oh gawd, I go away for some time, and these types of posts still float around here?
Dave Kreskowiak wrote: If you can't dig around in your brain and write the code yourself, what good is your degree then?
Excellent point.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Notice the rush to serve up some code to you. Seriously if you looked through the forum your would run across this type of question regularly and they always get a negative response. Do your own work, as Dave said what good is serving up someone elses code as your graduation project. Thats called CHEATING.
You've thought of an idea (half the job) now do the research to find out how you can make it work. Excercise those little grey cells in there and try Google.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
it's not that i'm looking for the solution easily..i tried brainstorming for long bt got tired..!
i only need tips that will make me think easily..if ur not gonna help then why is this website available then..!
|
|
|
|
|
People here, generally, do not spoon feed. Also, you are doing a course that expects you to learn something. If you search the web and find some code and just copy paste it to pass, then there no use doing the course.
Here are a couple of things to think about:
1. How are you going to send the notification? Mail, popup, alarm etc?
2. What kind of application this is? Windows based, web based?
At a very high level, your application should work like this:
Any time something is sold, you will be updating the quantity in database. At the same time place check such that when the product quantity goes below a certain level send your notification.
In the end it is your project so you should be thinking about this. In case you get stuck during the project and have a specific question, post it here and and I am sure some one will show you the right way.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
yea i guess ur right...thx for the tips anyway...
|
|
|
|
|
I wasn't trying to give you a smart ass answer. I wasn't sure but I though you were just asking how to display the message. If you were asking how to do this project though it's like d@nish said, people will point you in the right direction or give you 1 or 2 lines of code but they aren't going to write your whole program for you.
|
|
|
|
|
MikeMarq wrote: I wasn't sure but I though you were just asking how to display the message.
4th year compsci student needs a tutorial on MessageBox.Show()? Ouch. Not much belief in the education system, huh?
|
|
|
|
|
I am a relatively new VBA user and this is my first post (formatted better).
I am using Excel 2002 sp3 with VBA (help shows VB 6.03 version 1024) on an XP sp3 machine.
I have a project with one workbook that has one form - frmRecordJob.
This form has a calendar control, a combo box, 2 listboxes, some labels, and 2 text boxes.
The 2 list boxes (lstCode1 and lstCode2) are in a frame.
lstCode2 was created by copy/paste from lstCode1.
Checking their properties shows them to be identical except for the tab indices and top properties.
The value and text properties are both empty, with no blanks in field.
Both listboxes get their row source set in the form initialization routine.
These listboxes are not changed in any project code other than the form initialize event.
If I close Excel, restart Excel, open the workbook, immediately start the VB editor, open and step through the form initialize procedure, the following occurs:
Private Sub UserForm_Initialize()
*** some irrelevant code left out here ***
With lstCode1
.RowSource = strRngBaseTable
End With HERE lstCode1.Value = ""
With lstCode2
.RowSource = strRngBaseTable
End With HERE lstCode2.Value = null
End Sub
Why are the 2 list box values be different at this point?
I don't know if they should be "" or null, but I would think they would be the same.
Would they normally be "" or null?
At the end of the initialize procedure the form is shown and the 2 list boxes do not have any values selected. This is correct.
The form has a command button on it. If this button is clicked (no other mouse or keyboard actions) the click event procedure shows the following.
Private Sub cmdOK_Click()
Dim lng01 As Long
Dim bValidateNewGroom() As Variant
ReDim aryGroomDataFlags(1 To 6) As Variant
'If no Code1 entered
If IsNull(lstCode1) Then 'HERE lstCode1 = "" as before
lstCode1.Value = "" 'This line is not executed (correct)
End If 'HERE lstCode1 = "" as before (correct)
'If no Code2 entered
If IsNull(lstCode2) Then 'HERE lstCode2 = null (as before)
lstCode2.Value = "" 'This line IS executed (correct)
End If 'HERE lstCode2 = null (should be "")
The following (next) statement blows up with runtime error 94
"Invalid use of null"
I think this is because lstCode2 is null
'If new job data is valid
aryGroomDataFlags = ValidateGroomData_
(calGroomDate.Value, _
cmbAnimalName.Value, _
lstCode1.Value, _
lstCode2.Value, _
txtExtra1Charge.Value, _
txtExtra2Charge.Value)
My questions:
Why would the 2 list boxes be initialized differently (1="",2=null) ?
Why after lstCode2 is set to "" it still shows its value as null?
|
|
|
|
|
Hi,
do not create a new thread, you could as well have edited the existing thread.
My answer there is still valid.
|
|
|
|
|
I am looking for how to reset my listbox to the first item, which is "blank". I am selecting answers to survey questions, and then copying and pasting them to another worksheet. I know how to do this in VB. What I want to also do, is reset the listbox's to the first item, which is simply Blank. I am using Excel 2007 with Vista.
The linked fill range is AG1:AG6, with AGI being Blank. The linked cell is C100.
I'm sure this is not a difficult thing to do, but i simply need some assistance in determing how best to get the listbox back to the blank position
Thank you very much
Marty
|
|
|
|
|
Hi,
this isn't clear.
if you want to change the content, work on ListBox.Items; that collection has a Clear() method.
if you want to scroll the ListBox, set ListBox.TopIndex
|
|
|
|