Comatose 290 Taboo Programmer Team Colleague

(Read Edit To Prior Post)

In spite of the name 'virtual memory' the paging file is really just a chunk of reserved hard drive space where data may be written and retrieved as needed. Since the paging file and operating system files are by default located on the same drive, concurrent access to both locations is impossible. One or the other has to wait, slowing down overall system performance...

Comatose 290 Taboo Programmer Team Colleague

Strange.... my benchmarks show a significant improvement on system speed with page filing disabled..... I wonder why that is.... I can't imagine any time that reading to and writing from the hard-drive is going to INCREASE speed over the same information being kept in RAM....

You can read the same basic information I posted previously from Ryan Meyers, A developer on Microsoft’s Windows Client Performance Team: http://blogs.msdn.com/ryanmy/archive/2005/05/25/421882.aspx

Comatose 290 Taboo Programmer Team Colleague

Is he behind a router? Are either of you behind a firewall?

Comatose 290 Taboo Programmer Team Colleague

I feel the need to go into detail about this....
The prefetch, is used in conjunction with Page Filing (Virtual Memory). Anybody who has spent any time with a computer, knows one simple truth. Hard-drives (even the fastest ones ever made) are still horribly slow. Regardless of what kind of drive... Raptors in raid0, SCSI, even solid state drives are the slowest part and the biggest bottle-neck of a computer system. So, there are typically only two reasons why accessing the hard-disk is done. One is when the application specifically demands it.... such as to open a file, or save the data. The second is called a hard fault. This happens when a program wants to access memory that has been written to the disk via Virtual Memory (paged), and it needs to be paged back into ram.

Programs often use dependency files, like DLL's, which contain a bunch of functions the program can use. In order for the EXE to run properly (or in some cases, even at all) the required DLL's must be loaded into memory. The Prefetcher tracks what code pages are used by an application, and the next time that application loads, it loads those pages in advance as soon as it's got some idle time, instead of waiting for a hard fault to happen when the program needs to use the DLL.

I don't personally use Page Filing (Virtual Memory) because I have enough RAM that I don't need to …

Comatose 290 Taboo Programmer Team Colleague

Looping is a fun trick where you can do something a number of times or until a specific condition is met. There are a few kinds of loops, but two of the main ones are a "for loop" and a "do loop". A For loop is a way to execute the same code, a specific number of times. So, If I wanted to add the numbers 1 to 10 in a listbox, I could do this:

for I = 1 to 10
     list1.additem I
next I

What happens here, is that the variable I starts at the number 1... so the first time list1.additem is executed, I will be 1. Then, when it hits the line that says "next I", it says "ok, is I equal to 10 yet?", if the answer is no, then it adds 1 to I, and does it all again. So the second time, I will be 2, and then 3, and so on until it reaches 10. This is really helpful when you want to get a certain number of random numbers. If you only need 6, you could do for i = 1 to 6 . For reasons that I don't want to go into here, MOST VB programmers usually start a for loop at 0. So, to add six items for i = 0 to 5 . This isn't required, however, but if you view other people's code, you might see this quite often.

The other kind of loop I …

Comatose 290 Taboo Programmer Team Colleague

I'm sure one of the expert residents (nudge at comatose) can explain a lot more....

No Pressure There! :eek:

Here is a small breakdown of the way it works. When you call the rnd function, it keeps the seed value in memory. Calling rnd again will give you the same number. When you call randomize, it resets this stored value. See, computers generate Psuedo-Random numbers. Think of a very long list of numbers, and the computer always returns the values in the same order, but it doesn't always Start at the same place in the list.

Waltp is right, in that you only actually need to reset the seed once. Form_load is a nice place for that, but it won't cause any problems re-seeding the psuedo-number generator. It is, however, not very good programming style to re-seed the number generator.

I call randomize with timer as the seed ( randomize timer ), which just make it a little more psuedo-random. Should you want to know the last random number called, pass 0 to rnd, and it will tell you the last random number generated, such as lastrand = rnd(0) . I have no clue why you would want to do that (unless it's to make sure the new number is not the same), but you can.

The rnd function returns values smaller than 1, but greater than or equal to 0, which sort of sucks. You can fix this, though with a little function:

Public …
Comatose 290 Taboo Programmer Team Colleague

Visual Basic is no longer maintained by Microsoft, and can not be purchased anywhere that I know of.... you might be able to get a copy on ebay. VB Express can be downloaded here: http://msdn.microsoft.com/vstudio/express/vb/, but any questions regarding it should be directed to the .NET forum, since this is legacy VB, and the languages are, in fact, different.

Comatose 290 Taboo Programmer Team Colleague

It might be a bit more helpful if you can attach the excel document (as a .zip if necessary). One problem, is that you are trying to reference a property of an integer, which is not an object. For example, the variable i is going to be a sequence of numbers starting at 1, and ending at 10. So, the first time through the loop, I will be 1 then 2, etc.

So, even though you are trying to concatenate ProgramWork.PWTitle and the number referenced by i. VB still thinks you are trying to get the .text property for the number represented by i. So, it flips out. You MIGHT be able to make it work like this Range("PWTitle" & i).Value = ProgramWork.PWTitle & i & .Text but I'm not sure that will fly either. Let me know how it turns out, or attach the excel document.

Comatose 290 Taboo Programmer Team Colleague

Yes a VB Macro. Click Tools, Macro, Visual Basic Editor. Then click the Insert Menu, and Choose "Module". Then paste this into the module:

Public Sub ColumnCountAbove()
' /* ************************************************ */
' /* SubRoutine To Tally The Total Number Of Columns  */
' /* Which Have Values Greater Than A Specified Value */
' /* ************************************************ */

' /* Declare The Variables That We Plan To Use */
Dim ActiveColumn
Dim AllAbove
Dim TotalAbove
Dim I

' /* Get The Currently Active Column */
ActiveColumn = Excel.ActiveCell.Column

' /* Retrieve Information From The User, Regarding The Control Number */
' /* (That is, The Number From Which We Compare All Others To) */
AllAbove = InputBox("Above What Number?")

' /* If The User Enters Nothing, Just Quit */
If AllAbove = vbNullString Then Exit Sub

' /* Set Our Counter Variable To 1 */
' /* This Variable Keeps Track Of Which Row We Are In */
' /* And Which Row We Are Going To */
I = 1

' /* Since We Haven't Started Comparing Anything */
' /* The Total Tally Of How Many Are Above The Said */
' /* Numbers Should Be Zero... */
TotalAbove = 0

' /* Loop Until We Reach A Blank A Cell */
Do Until Cells(I, ActiveColumn) = vbNullString
    ' /* If The Value Of The Cell Is Greater Than The Value The User Gave */
    ' /* Then Add 1 To Our Tally */
    If Val(Cells(I, ActiveColumn).Value) > Val(AllAbove) …
Comatose 290 Taboo Programmer Team Colleague

Good Job Here Agrothe (Andrew)

Comatose 290 Taboo Programmer Team Colleague

I'm not 1000% sure I understand what you are asking.... I'm guessing you have an MDI form as like a remote control or controller (navigation) window, and when you do something in that window, you want it to display the corresponding MDI form..... BUT that MDI form COVERS your remote right? Do you have the MDI form that covers the remote set to maximized?

There are probably 2 solutions here (assuming I have the correct problem). One is to set the MDI Navigation Form to "always on top", so that even if the other form covers it, it's Z-order will remain the same. The other solution, would be to not have the secondary forms (the one's that cover the navigation form) set to maximized, but rather, normal. Then on it's form_load (or resize, or whatever), have some code in there to ensure that the me.left is never less than the remote forms .left + .width .... let me know if I'm off course here or not.

Comatose 290 Taboo Programmer Team Colleague

Hmn, can this be a macro?

Comatose 290 Taboo Programmer Team Colleague

WaltP is correct. You can also call functions, events and methods this way too. For example, if you have a button on form2, and you want to "click" it from a button on form1, you can do something like form2.command1 = true .

Comatose 290 Taboo Programmer Team Colleague

Can you attach the project to a post, or e-mail it to me (in a .zip [e-mail is in my profile]) so that I can have the pictures and everything needed for this to run?

Comatose 290 Taboo Programmer Team Colleague

Sweet! ;)

Comatose 290 Taboo Programmer Team Colleague

If I'm not mistaken (yeah, sometimes, but not frequently ;) ) this should work:

Fname = Application.GetOpenFilename
With ActiveSheet.QueryTables.Add (Connection:="TEXT;" & Fname, Destination:=Range("A1"))
end with

Now, I've tried the code, and maybe my excel VBA Coding is a bit rusty... but I don't get it loading into any cells that way. I think the file will have to be opened through code, read in, and put into the cells..... but let me know if the above works for you, and maybe I can figure out why it doesn't for me :eek:

Comatose 290 Taboo Programmer Team Colleague

:eek: easy girl! Just being playful Dani.....

Comatose 290 Taboo Programmer Team Colleague

:cheesy: You know that looks goofy on Visual Basic code right ;)

Comatose 290 Taboo Programmer Team Colleague

Ok, Umn..... How do I escape BBCode Tags? For example, I have a post where the user uses a database (with code), and the problem is that one of the fields is "code". So, what I mean is, it gets referenced like this:
Select (Code),[Price],[Res] from [tt]" & " order by (Code),[ID]" See there? (Code) (with brackets) is a database field, and gets referenced with brackets. This uh, is a conflict with BBCode tags. Since we know that (CODE) (with brackets) is how to start a code block in a post..... so, how do I make it SHOW (CODE) (with brackets) in a code box??? Get me?

Comatose 290 Taboo Programmer Team Colleague

There was a day when I'd say yes. As of right now, we have a few hot threads about this....(not about excel, but about reading from a serial (or parallel) port with V6:
http://www.daniweb.com/techtalkforums/thread52807.html
http://www.daniweb.com/techtalkforums/thread52505.html
http://www.lvr.com/parport.htm#Programming

Basically, it looks as though in XP we have to try to use this new DLL, but it's giving problems to some people. If you can get it to work, it's easy enough to port the data to excel.

Comatose 290 Taboo Programmer Team Colleague

Is this a homework project? If so, what are the specs? what have you done so far? What do you need help with?

Comatose 290 Taboo Programmer Team Colleague

Right on. There are two types of .dll's. A "Real" dll, which has an entry point, and usually doesn't have any dependencies... and an ActiveX Dll. The declare statement is used to reference a function that is in a "Real" DLL, while going to "project/references" and adding a references to a DLL works only for ActiveX Dll's. So, to my knowledge, you actually can't use the declare statement on an ActiveX dll.....

Since you found the solution, however, I'm going to go ahead and mark this thread as solved.

Comatose 290 Taboo Programmer Team Colleague

Sorry. You can access the MSDN library from microsoft here: http://msdn.microsoft.com/vbrun/, but the actual install CD's (the MSDN Library and Help Files) Come with VB6, and you may need to get them from ebay (since microsoft no longer supports it).

Comatose 290 Taboo Programmer Team Colleague

Does it compile though the IDE (without the use of the package and deployment wizard)?

Comatose 290 Taboo Programmer Team Colleague

Hmn.... for some reason it's not setting the labview parent...... I don't have labview, so I can't test it, but the same code works for notepad (if I change the class to "Notepad", and then run notepad).... maybe we'll have to go to the text file way.... I can give you code to open the file, and read in the values, and I can give you info on PSET, but I don't know much about graphing or plotting, so after that you will be on your own..... I wish I knew why it won't kidnap labview :(

Comatose 290 Taboo Programmer Team Colleague

if you minimize the VB form, does it minimize the labview window too?

Comatose 290 Taboo Programmer Team Colleague

K, Try this and let me know what happens.

Comatose 290 Taboo Programmer Team Colleague

Just to make sure, that's JUST the graph that we want to steal right? Not it's parent, or anything like that, the mouse directly over the plotting area, right?

Comatose 290 Taboo Programmer Team Colleague

First, you'll need to get the class name of that window.... I have a program that does this: http://www.aftermath.net/~coma/downloads/getclass/getclass.zip, once you download and install that, run the "Getclass" program, and it will show you a textbox and a button. The textbox will contain the windows current hWnd (The number assigned to it by windows), The class name of the window, The caption (title) of the window, and it's thread id. The only crucial one that we need is the Class, but if it has a caption, then both would be even better. So, once you are running the program, hold your mouse over the graph, and write down the class name (and caption if applicable) and post it here..... then we'll write code to do it.

Comatose 290 Taboo Programmer Team Colleague

You'll need to post the text file (a portion of it) so I know the format we are dealing with.....

FYI: I wasn't talking about asking for their permission. I was actually talking about taking it..... without permission. So that Labview would still be running, and it would still be plotting the things to the graph, but the graph would be kidnapped into the VB form.

Comatose 290 Taboo Programmer Team Colleague

Hmn, you should be able to just set the reference to the filename.... so in an anchor:

<A HREF="http://www.yourserver.com/yourfile.zip">Your File</A>

that's if you want to link to it.... to force it, you may have to use some javascript. Something like:

<BODY onLoad="window.location='http://www.yourserver.com/yourfile.zip';">
Comatose 290 Taboo Programmer Team Colleague

So, what you'll need to do, is open the text file, and read in the data. Keep a count of how many lines there are. Then, in a loop, read any added data (any lines greater than the last read) and plot them. Do this over and over until the file is done updating, and you should be good to go. Something to keep in mind, is that file is going to get big probably, so... you may want to check it's size every so often, and if it reaches a certain size, delete the file, and reset your count. I don't know what kind of effect that's going to have on labview though..... it might get pretty pissed about you deleting the file.....

Is it necessary to actually have the VB app plot the data, or would having the VB app kidnap the graph area work?

Comatose 290 Taboo Programmer Team Colleague

Is the textfile constantly being "ADDED" to, or is it constantly being UPDATED (there is a difference, ya know... added to means that it leaves the data alone that's already in the file, and just adds more data to the end, while updated means that it's possibly changing the data already in the file)

Comatose 290 Taboo Programmer Team Colleague

Ok, Let me explain the best I can....

In the file you attached, you see this line #include <iomanip> means that this C++ program wants to use functions, variables, and other programming "things" from the iomanip file (probably .h). Vb has no real way of doing this. Now, beyond that, the information in that file (iomanip) is what is needed to read from, and write to the serial port. Search the .cpp file for "sendByte", and you'll see that it is never defined in the attached file. sendByte is a function (method) that is probably defined in a class in iomanip. Even if you had access to iomanip, you probably wouldn't be able to convert it to VB anyways, since vb doesn't allow such low-level access to hardware. Hell in C++ you can directly reference video memory, and use pointers to hardware addresses, all things of which are too low-level for VB.

VB CAN read from and write to a serial port, but it requires the use of the API. This was true until win2k and XP. There was a file (win95IO.dll, I believe) that had functions for doing just that. Since the release of the later windows versions, we have yet to find a suitable replacement for that .dll. There is a free dll available, that will allow you to read and write a serial port, but people with service pack 2 have been having troubles making it work correctly. So, if you want to make a …

Comatose 290 Taboo Programmer Team Colleague

Sure, it's not difficult to do either, but as I said, I'm guessing the problem is with the .dll, not how you are calling it. If there is no code (just a blank project), and you reference the activex dll, the problem has to be there. (or it could be a bad installation of vb6, but I don't think that's the problem).

The activex .dll is registered correctly in the registry right? (regsvr32)?

Comatose 290 Taboo Programmer Team Colleague

I've never tried to use javascript in a VB6 application, but the chances of that actually working are nil and none. I'm not sure what your activex dll is actually doing, but I'll bet the problem with the crash, is due to the code in the .dll.

Comatose 290 Taboo Programmer Team Colleague

The problem with the line (470) is without a doubt, the fact that the length is equal to 0 in the left function. Check this:

'BigString$ = Left(BigString$, Len(BigString$) - 1)
BigString$ = Left(BigString$, Len(BigString$))

I removed the -1 (since the length of bigstring$ was 0) and the left function didn't flip out. It flips out (and returns an invalid procedure call or argument) when left is being called with a negative value. The second argument (parameter) to left, MUST BE a positive value (or 0, which I suppose is also positive). Check the length of bigstring$ first, such as: if len(bigstring$) < 0 then if you are having problems after removing that line, then there is more than 1 problem in the code, and I'm guessing it has to do with the length of bigstring$ being less than 0 also....

Comatose 290 Taboo Programmer Team Colleague

PG's Right. You should test if the string is empty (or how long the string actually is) before trying to get the left value from it....

Comatose 290 Taboo Programmer Team Colleague

You should start off reading a tutorial about it.... here is a good site to start at: http://www.vbtutor.net/vbtutor.html

That should help to give you a general idea of what is going on, and help you to be able to at least start getting involved in VB. Once you have a fairly comfortable idea about the language, then start doing projects that you think would be interesting.... something like a rolodex program...

Comatose 290 Taboo Programmer Team Colleague

Thanks for following up the solution.... it's a great help for others following and having the same problem.

Comatose 290 Taboo Programmer Team Colleague

That's the problem.... from what I can tell, the only solution to the problem is to download the .dll (http://www.lvr.com/parport.htm#Programming) and try to use it. You USED to be able to use vbin and vbout of the .dll that came with 9x.... which carried on until 2k. Since now that .dll NO LONGER EXISTS, we have to try use the one at lvr.com. I haven't used it, but it seems to be well documented.

Comatose 290 Taboo Programmer Team Colleague

Hi Kim,

I'm currently looking into the situation of making VB6 read and write data to/from serial / parallel ports. This worked great up until 2k and XP, where they removed a .dll from the OS that was required for VB to Read and write to the IO ports. Check this thread: http://www.daniweb.com/techtalkforums/thread52505.html

Comatose 290 Taboo Programmer Team Colleague

Then, if you can past an example of that file.... I can see about how to go about reading it. What I'm guessing you'll have to do, is have labview write a file (either one, text or excel, vb can work with both) and then get a list of points out of that file, and plot them using pset or something.....

Comatose 290 Taboo Programmer Team Colleague

Oops :o New Addition. Well done Dani.

Comatose 290 Taboo Programmer Team Colleague

Eak, does labview write a .txt file, or some means in which VB can read the data?

Comatose 290 Taboo Programmer Team Colleague

Cool.

*Adds it to his list of "things"*

Comatose 290 Taboo Programmer Team Colleague

Hmn, can I ask what you did to fix it (or, was it just a stroke of luck)?

Comatose 290 Taboo Programmer Team Colleague

So... the glass is half empty? From your point of view, iamthwee, what features / additions would YOU like to see, that you WOULD pay just a little money for? Anyone for that matter, what things could Daniweb offer, that would entice you to want to be a member?

One solution, that might help a little bit, is to consider accepting donations by some other means than paypal. I have a lot of friends (as we are all paranoids) who won't even consider the idea of having account information online. Maybe it's a paranoia, maybe it's old-fashionism, but sending a money order is the only way some people will approach the concept at all.

Comatose 290 Taboo Programmer Team Colleague

Is the database (or any part of it) password protected?

Comatose 290 Taboo Programmer Team Colleague

Indeed, welcome.