How to modify an output value in LabVIEW? - labview

I am very new to LabVIEW and what I want is to know if it's possible to modify an indicator. I have a loop, and in every iteration I want to add a new value (given by the user via a control) to that string indicator, and to display it? I tried many ways, but since it is an output none of them worked. Is it possible to do that? Thank you.
I have also tried using a feedback node, but I think this somehow gives me an infinite loop.

In LabVIEW, an indicators state will be updated every time that it receives a new value.
By far the easiest way to do this is to simply run a data-flow wire into an indicator terminal.
Beyond that you have local variables, and property nodes which add additional concerns.
In your case it looks more to be an issue with the logic associated with your display update than with your actual updating of the value.
(Additionally, why are you using a string display to indicate a numeric value? Using a numeric suddenly simplifies all of your logic.)

To keep a running total - or similar value - in a loop, use a shift register.
This is just a minimal example in which the loop repeats every second until you click the stop button, but you can adapt it to how you want the control flow to work.

Related

Can Access ensure a new form record displays all fields?

I have a database where I don't want some fields showing depending on data in other fields. I'm still new to VBA, having learnt how to do things I need via the internet (there's not much call for it in my job so like to try it out on side projects) for the things I need and have managed to create some code that hides certain fields that aren't needed, depending on what's been entered in another field and that works okay, if not perfectly (I'd like it to only work on the current record and not all of them at once but will worry about that later). My problem is, if I'm entering information onto a record and any of those fields become invisible exactly as I would want them to, then if I have more records to complete and load a new record, those hidden fields are also hidden on the blank record before any data has been entered and I want each new record to show all fields from the outset.
Another thing I've noticed is that if I close the database, next time I go into it the hidden fields have unhidden themselves again so I know I'm missing something important.
Here's a screenshot of a bit of the code where I want 2 other fields (What_reason and Date_sent_to_new_owning_School) to be visible depending on whether the answer in the current field after update is "Standard" or "Non-standard":
I'm sorry if this is really entry-level stuff but I AM entry level and trying to learn. This bit does work, albeit not perfectly as I'd like it to only work on the record I'm in at the time, and not go through and hide that field in all the other records at once (which it's doing).
I've searched everywhere but can't find the answer and although I've tried, I'm nowhere near good enough at VBA to try and use common sense to work it out. Is this something that can be done? I'm okay with computers generally and with Access too but I'm aware there's an awful lot I don't know and this is why I'm trying to do new things and learn stuff that I've not used before. I have tried all day to get this to work but am admitting defeat and am hoping somebody here will be able to help me. I'll probably need 'idiot level' advice if that's possible, I know my limitations. :)
Do you know how to use the Event tab in the Property Sheet? You can set all of your fields to [field].Visible = True on either: On Current, On Load, or On Open
Screenshot of the Property Sheet and for the field that determines the visibility of all of the other fields; you can use the Event: After Update so that way when you click/tab away from that field, it'll make those changes for you!
Property setting affects ALL instances of control. Control will be visible/not visible for all records depending on conditions of current record. Therefore, dynamically hiding controls on form set in Continuous or Datasheet will NOT give the desired result of
only work on the current record and not all of them at once
Db is not going to 'remember' dynamic setting - code needs to be executed when form opens and/or navigating records - so it is needed in OnCurrent event as well as control's AfterUpdate.
Conditional Formatting can dynamically enable/disable textbox/combobox by record although control is still visible.

How to copy value in Numeric Indicator to Numeric Control in LabVIEW program?

How to copy value from numeric indicator to Numeric control in Laview program? That is Numerical Control should use the value that is displayed in the indicator.
The easiest way is to use local variables. Right click on the indicator, create -> local variable.
Then you can change the local indicator to control and wire it to control' local variable.
There are several ways to do such thing:
The easiest way (if you need value from indicator, as an input value to another block - simply put together wire with block input.
If it has to be control itself, then use local variables as #KhachikSahakyan said. What's more after creating local variables you can change it behaviour from read to write by right mouse click.
You can also use shift registers to pass data in some cases.
If such explanation does not solve your problem please provide more info, such as screenshot with fragment of your code.

referring to different textboxes on each iteration

I'm making a Visual Basic program. I have a page where I want to be able to scale anywhere from 1 set of two textboxes and a label all the way up to 30. I'd really like to keep the display as simple as possible, So I'm trying to make buttons like add batch and remove batch that lets me adjust the boxes shown from 1 to 30.
I know that I can use a case statement or a if statement or even making a function that does one of those for me so I don't clutter up the main code, but that just seems so klunky. Any suggestions on a way that I can refer to one set at one time and another set at one time?
I ended up creating a class that and passed references ByRef to the class. Created methods of Show*( and Hide() that show and hide all objects that were passed to the class (just changing the Visible property)
Created one object of my new class for each batch set. Made an array with those objects in it, now I can call BatchGroups(3).Show() and iterate through my batches.
Still a bit of setup in my FormLoad event, but BatchGroup(txtBat1,txtBatQty1,lblBat1) and filling an array with those objects allows me to iterate through my batches whether I am adding, removing, adding 5 at a time, removing all but one... take your pick.
Could probably build an array with groupboxes as easily to refer to the whole group at once, but groupboxes would have looked somewhat tacky in this situation, I preferred to create my own object oriented groups.

Cocoa textbox to update variable

I've got a textfield with number formatter which is bound to a variable with Cocoa bindings.
There's also a stepper which I've bound to the same variable to increment the value, I've used an NSLog to test and it works great.
My problem is: Whenever I type a number into the box the variable isn't updated unless i hit enter. How does NSTextBox know when the user is finished entering? Is there a way to dynamically update the variable after every digit entered?
Many thanks
Rich
First, are you sure you want it to update immediately? One of the user's keystrokes could be an invalid character (ie, not a number). An NSNumberFormatter can help but I believe you still have to "commit" the entry before it will validate it as a proper number entry.
Second, you could always implement the -textDidChange: NSTextDelegate method. Again, same problem as above, though. Invalid input could trigger. To work around this, you could try creating an NSNumber from the string input and if you don't get an NSNumber, don't bother reacting until you do (and if the field loses focus with invalid input, change it back to its last valid value) but then you're duplicating the "validate on commit" NSNumberFormatter behavior you get for free.
Switching on the "Continuous" property for the control in Interface Builder should make the field fire its binding as the value is changed.

Listen for Table Filter Activation

I have a table that has a series of filters across the top of it (as per usual.) This table feeds a massive graph that has multiple series of data in it. In order to hide different series of data I have grouped the information in the tables. I can then click on the minus button to remove a series of data from the graph by collapsing the group, or click the plus button to add it back in the same way. Yes, I know, not the best solution. It was an early effort, what can I say? My default is for all data to be hidden (all groups collapsed).
I have a user (a very important user) who wants to be able to use the filters across the top to find the specific series they are looking for. The filter will find the collapsed series just fine, but the series will not display because it is collapsed.
So, What I'm trying to do is get all groups to auto-expand when the filter is activated. This should work as a stop gap measure until I can simply redesign the chart.
The Problem: I can't figure out how to make Excel notice when the filter has been clicked on (or otherwise used). I've tried using Worksheet_Change and Worksheet_SelectionChange, but neither of them activate the code I have set up in the listener. That code, FYI, checks to make sure the filter is in use and adjusts the groupings accordingly. It should work fine if I can just get Excel to notice it's existence.
I've looked into making my own listener, but there's nowhere in the code I can insert it to make it activate. I just need a listener that will notice when the filter has been changed.
Any thoughts? After an hour of searching I'm stumped...
Okay, after some research I figured out a work around. The big problem here is that changing a filter does not raise any events that can be heard by VBA. Big problem.
Simple Solution: Create something that will activate a listener.
What I ended up doing was finding a cell somewhere outside of my table that wasn't going to be affected by the collapses, then I added a very simple formula (=Count(H:H)). Now whenever the table is collapsed the count is affected which activates the Worksheet_Calculate listener. And voila! I can dynamically change the groupings all I want :-).
So there you have it. If you need to detect a filter being activated via a Worksheet listener, you just need to set up a formula to activate the calculate listener.
Reference: [MSDN Article on the same thing].1 There is apparently a much more robust way to fix this problem as well which is detailed in the article.
You mentioned table, so assuming it's PivotTable you may try,
Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
If it's simply a Targe Range change then,
If Intersect(Target, Range("A2"))