|
OK,
so for N float numbers:
- use StringBuilder, give it initial capacity of 7*N
- fill it with your floats and try to keep it as short as possible, hence:
- try if it works without the space
- do some formatting (to avoid stupid decimals as in 0.3333333333333333(
- don't provide unnecessary resolution (if 0.00 is sufficient, don't use 0.0000)
- chop off trailing zeroes
- don't put sleeps, GUI stuff, etc in the fill loop
- update something on the GUI when the StringBuilder is filled
- give it to SendArbDate
- update something on the GUI when that method returns
- don't worry about some extra code in the fill loop, as long as it is not sleep, thread related
or GUI related.
I ran a simple filler for a megabyte stringbuilder; it took less than 50 msec, so that is
definitely not where the problem is.
You still haven't told much about the interface though; TCP/IP may or may not indicate Ethernet;
you can run it on a serial port too!
Warning: the device or its library may dislike a terminating ", " so strip it off before turning
StringBuilder into string.
Final remark: if either the library or the target device does a long computation (such as a
Fast Fourier Transform, which isn't always fast!) SendArbData might not return for a long time.
|
|
|
|
|
The manual isn't really clear on this but by trying I figured out that the device needs 4 decimals after the comma to get an accurate output.
For example when I set the Vmax to 9 volts and I want it to output 3 volts (1/3) then I need to set the data point to 0.3333333333333333333 if I had infinite accuracy. But just by trying I found out that by setting the data point to 0.33 i gives me 2.7 volts and when I set it to 0.3333 it gives me 3.01 volts.
I think you might be onto something with the GUI thing.
To be honest my first version wasn't with stringbuilder I think. When I first wrote the code I put it under a button using normal string. Then when I found that was too slow I built the thread thing then later on I put stringbuilder in there.
Okay after some trying I found that the culprit in this case was the progressbar which was being updated every loop. When I just use the stringbuilder it's quite fast.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim Rnd As Random = New Random()<br />
Dim Dbl_RndData(65535) As Double<br />
Dim Str_RndData As StringBuilder<br />
Dim i As Integer = 0<br />
<br />
Str_RndData = New StringBuilder()<br />
<br />
' Fill the Double array with random data<br />
For i = 0 To 65535<br />
Dbl_RndData(i) = Rnd.NextDouble<br />
Next<br />
<br />
' Convert the data to a string using stringbuilder<br />
For i = 0 To 65535<br />
Str_RndData.Append(Dbl_RndData(i).ToString("0.0000"))<br />
Str_RndData.Append(", ") ' Append a comma to get CSV format<br />
Next<br />
End Sub
Thanks for the help.
|
|
|
|
|
You're welcome.
Just out of curiosity, how fast is it now?
|
|
|
|
|
Using this code:
Dim Rnd As Random = New Random()<br />
Dim Dbl_RndData(65535) As Double<br />
Dim Str_RndData As StringBuilder<br />
Dim i As Integer = 0<br />
Dim StpWtch As Stopwatch = New Stopwatch<br />
<br />
<br />
Str_RndData = New StringBuilder()<br />
<br />
' Fill the Double array with random data<br />
For i = 0 To 65535<br />
Dbl_RndData(i) = Rnd.NextDouble<br />
Next<br />
<br />
StpWtch.Start()<br />
' Convert the data to a string using stringbuilder<br />
For i = 0 To 65535<br />
Str_RndData.Append(Dbl_RndData(i).ToString("0.0000"))<br />
Str_RndData.Append(", ") ' Append a comma to get CSV format<br />
Next<br />
StpWtch.Done()<br />
<br />
TextBox1.Text = StpWtch.ElapsedTime.ToString
And this Stopwatch counter:
http://www.codeproject.com/KB/vb/vbnetstopwatch.aspx[^]
I get 0.196240863014713 seconds
|
|
|
|
|
I am retrieving data from database with list Box control. I like to show different items are different color depending upon condition. For example if I presenting student name in list box, when populating all student name, the student name who passed show in green color and who failed in red color. Please provide help in vb.bet.
|
|
|
|
|
Hi,
This article[^] demonstrates the nice things a ListBox can do. It is C# code, but the same applies to VB.NET
In essence, the listed items don't have to be strings, they could be any kind of object;
and a ListBox supports user-drawing, so you decide how things look.
|
|
|
|
|
HowI can hide the selction of a button disabled after then mouse is outside it? (VB.net)
thanks
|
|
|
|
|
I am not quite sure what you are asking.
Are you referring to: changing focus, hiding the button?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Hi,
Is there a good instruction how to create on add in and install it on someone else his/here pc. About 20 persons will use the same add in. So where must i copy it? How do I activate it? and so on.
some examples are apriciated
Jan
|
|
|
|
|
Hi Jan,
Tye to use VSTO (Visual Studio Tools for Office) for VS 2008. This provides many features to developers to deal with Office application development.
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
|
Hiii
I m working on outlook Addins using vb.net 2005 and i want to select the profile (Sender User from ) My outlook.
Like
I Have 4 Profiles in outlook and when i send the mail i want to select the sender user in outlook.
I am using a custom windows form for sending mail. not a default outlook mail editor.
Please suggest how i select the profile.
Thanx
~Khatri Mitesh
|
|
|
|
|
Hi,
I create a simple program that can open a image in excel. But there is a problem, I want it to position a little bit lower because I have some data that i want to write above that image. And also how do I re size the image that i put in the excel?
Here is my code:
Dim xlsApp As New Microsoft.Office.Interop.Excel.Application
Dim xlsWSheet As New Microsoft.Office.Interop.Excel.Worksheet
Dim excelFiles As String = "c:\Test.xlsx"
Dim pic As String = "c:\MsC.bmp"
xlsApp.Visible = True
xlsApp.Workbooks.Open(excelFiles)
xlsApp.ActiveSheet.Pictures.Insert(pic)
xlsApp = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
Anyone change help me how to do the position of image.
Thanks
Regards,
Jessie
if(you type your code here) {
Messagebox.Show("You help me a lot!");
}
else {
You help me = null;
}
modified on Monday, July 28, 2008 4:55 AM
|
|
|
|
|
hi all
when i open at a time more then 5 report in crystal report by vb 6.0 then it give's error which error discreption below read it.
Run-time error '-2147189547'(80047cd5)
there are not enough concurrent access licenses to log you on. This system has 5 concurrent access license. Please try again later, or contact your system administrator to obtain more licenses. Licenses can be purchased direct from Seagate Software or through the Segate Software Online Store.
but i don't want to purchase, I want trap this error in vb 6.0 & give it only our msg for the same.
If any one know this solution then replay me if possible the replay with source code.
Thanx
|
|
|
|
|
does vb6 not have try/catch ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Nope - but On Error Goto should suit the requirement.
|
|
|
|
|
On error Goto it is not working it can not traped.
give me other solution.
|
|
|
|
|
I have ran into this many times in .net, not sure if its the same with vb6.
make sure that once you load the report into whatever it is your doing, that you use the ".close" to unload the report and release the licenses. You should be able to load it into a viewer and close it with no problems.
Hope this helps.
PS.
First post =)
|
|
|
|
|
Can i trap crystal report pop up msg in vb 6.0
|
|
|
|
|
Currently i am using Cstr(hddrive.totalFreeSpace) to list my current disk space. But the result which came out is in bytes, is there a way to covert the result to in terms of gigabytes??
|
|
|
|
|
Divide it by 1024*1024*1024, and you will have disk space in GB.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
Yes.. i know that is a way but is there a way which allow the display of disk space with any calculation. If i were to right click c:\ and click properties i can see the disk space both in bytes and GB. Can i display the GB potion instead of the bytes??
|
|
|
|
|
Subjugate wrote: Can i display the GB potion instead of the bytes??
No! That's absolutely impossible. No way! IM-POSS-IBLE!
...off to buy himself a magic GB potion.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
What makes you think the Windows "Properties" box isn't dividing by 1,024, too?
|
|
|
|
|
Subjugate wrote: Can i display the GB potion instead of the bytes?
No. You have to divide by 1024*1024*1024, as already mentioned. Has the thought occurred to you that maybe, just maybe, Windows Explorer does the same thing?
"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
|
|
|
|