Creating a self test program with save/import functions (images, description inside) - vb.net

I'm basically trying to create a program that will allow me to use textboxes to input questions and associated answers to test myself. Mostly, I just want to practice some things I've been learning for vb.net while taking an extra step forward.
Here's a mockup:
Any tips on how to do this? What I'm especially not sure about is how to have the textfile save/import work with adding back into comboboxes and making sure the correct questions and answers are associated with one another. I was thinking also that I could have some sort of check when I import a save file that shows me which questions and answers refer to one another
Update on form design:
Some things I'm trying to practice:
Using arrays
Saving/Opening files (text files in this)- in order to import into program
importing into program
Using the progress bar
Having a way to undo entries
Randomizing sort order in the combo box
Maintaining references between variables (like which answer
corresponds with which question) regardless of sort order or using
the undo function
Some posts in stackoverflow I'm thinking of using as reference:
Compare String with Strings in array
Best way to associate two strings of text in VB.NET
Array to combo box?
Update: Trying to be more specific on my question. Basically, I'm trying to use a list to account for all the inputted questions and answers, however I've only used really basic arrays before, like:
val(1) = "test"
val(2) = "this"
val(3) = "string"
Or the kind where you use a For x to z loop. Based on some stackoverflow posts I've gotten to the point where the code works in that (I think?) the list is updated and the combobox for questions and answers reflect what is on the list. However, I can't connect the two so that I can select things in the comboboxes and check if they are correct.
In terms of saving as a text file. I figured it would be simpler. Basically, have it output sort of like
"question goes here" ; "answer goes here"
"next question goes here" ; "answer goes here"
and so on. Then I can use the semicolon as reference in the code when importing. I've never done it before, but it's generally what I do for Microsoft Access or Excel text imports so I figured it was possible.
Code that I have so far (reddit post link): http://redd.it/2716tw

Related

Possible to manipulate text labels in report section headers using VBA? (MS-ACCESS)

Possible stupid question here...
But is it possible in MS-Access to programmatically manipulate text label captions in such a way that that a different caption will appear in the header of each report section?
Ie., The design view shows a text label object in the GroupLevel zero header, with a default caption of "blah"....but upon execution of a Report_Load() sub, the actual text displayed is different for each section in the report? Say, simply "Section 1", "Section 2', "Section 3" and so on?
My suspicion is that this is not possible, but just wondering if anyone has some creative ideas how to make it work.
I realize that there are other/better ways of accomplishing the same thing...but is such a thing possible using VBA and Label objects specifically (at the moment, this is an external constraint and one that I cant change).
EDIT: https://drive.google.com/open?id=1PID58qMyp_rNxv9tsQk38-Co9sDOFgzY
EDIT 2: Original post specifically designated LABELS as the only object for an acceptable solution. Edit to include LABELS and TEXT BOXES...which of course makes the question nearly trivial. Apologies to #peakpeak for my lack of clarity!
You can change the caption with
Me.<name of header>.Caption = "whatever"
Select Properties for the header in design view and find out and/or change the Name property. Me assumes that the VBA code is located under Microsoft Access Class Objects in the form you want to manipulate.
Actually, thank you for your help, but I have found something that appears to function as a decent work-around within the constraints I described above. Strictly speaking, this does not satisfy the terms of the question as originally asked (-1 to me for lack of clarity, and apologies to #peakpeak, who admittedly had essentially zero chance of answering this question as asked), but it this is close enough that it solves my immediate problem:
Change the object intended to contain my dynamic text from a label to a text box (duh!), keep all formatting settings, etc. the same so that the graphical presentation is unchanged.
Set the Control Source of the new text box to a public function, where the argument of the function is the name of a relevant field in the underlying query ("tName" in the linked example), so that the dynamic text box has a control source "=GetText([tName])" and the GetText() function is defined in the appropriate module for the report, and defines the text as desired, e.g.:
GetText(tName as String) as string
SELECT Case tName
Case "Albert"
GetText = "Section 1"
Case "Barry"
GetText = "Section 2"
Case Else
GetText = "Section 3"
'and so on
End Select
`
End Function

How can I build custom Word fields with VBA

I've found a question in stackoverflow: "How can I build Word fields with VBA" by JonnyGold.
I'm interested in the same question, but possibly on other reasons. The answers to JonnyGold question doesn't satisfy me. I'm still in MS-word 2003. My problem is to construct a custom word field, which would recognize a bookmark name around cursor location, saves that name in some custom variable/property, so that in a case of need a hyperlink of ref field could return a cursor to the said bookmark.
I need that mechanism to facilitate an easy work with a list of bibliographic sources, so that a user can by one click to go from a reference to a source and then to return back. Note that one source could be referenced in several different places and a user should be able to return to a reference, he/she clicked before.
I tried to use REF field with MACROBUTTON field inside, but MACROBUTTON requires double or one click on a button/text, which I want to avoid. I would like to create a field {RUNMACRO MacroName}, which would run a specified VDA Macro.

Is it possible to copy the contents of the Immediate window in Excel VBA?

Question
I would like to know whether it is possible to copy or extract the contents of the Immediate window in Excel VBA, so I can store it somewhere. I already know you can copy and paste from the window manually, I am interested in whether it is possible to do it with code (preferably in VBA itself).
Explanation
Questions similar to this have been asked a few times on SO (e.g. this and this), no-one has given a definitive answer and I was unable to find one from a quick search. Most of the time, answers respond asking why anyone would want to do that, and give ways to get around it in the circumstances provided in the question (e.g. how to output messages to a file or cell range). Given this, I have thought of a couple of example scenarios where someone might want to do this and cannot (easily) get around it.
Example scenarios
A) I am developing a large workbook including a large set of macros, debugging as I go. This includes using debug.print statements and directly querying in the Immediate window, e.g. ? myVar. At the end of the session, I would like to be able to automatically copy the contents of the immediate window into a log file, so I know what happened during my debug session afterwards. This could, for example, make use of the Workbook_BeforeClose event procedure.
B) I am working with two workbooks that contain VBA projects - one I can't edit, another that I can and am working on. The one I can't edit outputs debug information to the immediate window via debug.print that I would like to store somewhere (but I don't really care where).
Disclaimer
I ask this question purely out of curiosity. I suspect I already know the answer (it's not possible to do this), but I am not sure.
Yes-- but not with control-c .... select what you need and then drag and drop
1-Create a sheet named "debug.print"
2-Hide it:
Sheets("debug.print").Visible = 2 'xlSheetVeryHidden, only can be visible with vba
3-Create this function:
Function debug_print(c As String)
ThisWorkbook.Sheets("debug.print").[a1048576].End(xlUp).Offset(1).Value = c
Debug.Print c
End Function
4-Replace your codes "debug.print" to "debug_print"
5-Example:
Sub blablabla()
debug_print "i am doing whatever"
End Sub
But: Using "?" in the immediate window will not save
There is many ways to export this as file now like CSV, TXT, save in SQL etc...

How do I fill out fillable PDF Form fields using 4gl?

I have a PDF form that I'm filling out with data using progress-4gl. To date, I've been only filling in text fields using the following syntax:
put stream stream1 unform
"^global CHX_SINGLE_CE_PLAN3" skip(0)
"X" skip
CHX_SINGLE_CE_PLAN3 is the field name...
This code works when dealing with text fields but I'm trying to check a box instead of fill in a text field. I cannot find any documentation on this. Is checking a box on a fillable pdf form even possible with 4gl?
As far as I remember PDF Include has support for filling fillable forms. Whilst it's probably a bit over the top in terms of what you want to achieve, it's an open source project and so you may well find the answer to your question within the code itself.
Here's a link to the project page: http://www.oehive.org/pdfinclude
I discovered the answer, which I thought I had already tried before asking this question. The answer is you need to pass the value "Yes" (with capital "Y") in order to check the checkbox. The correct code in this instance is:
put stream stream1 unform
"^global CHX_SINGLE_CE_PLAN3" skip(0)
"Yes" skip
I believe this is the case no matter which language you're using

Editing contents of a labview array

I'm trying to increment specific elements by 1, in order to log results as they come in. I'm trying to read an element, add 1 to it, and then write it back to the same memory address. Why isn't this simple?
In code it would be something as simple as;
array1[element1] = (array1[element1]+1)
or
array1[element1]++
Arrays seem to be either read (indicators) or write (controls)? This is really frustrating, and there's very little help online.
You can use an "Array index/replace" element inside a "In place element structure":
You should use ReplaceArraySubset in the Array palette. For simple replacements, it's much faster than the In Place Element Structure
As an infrequent, novice Labview user I have the same problem ... until I found the code that I used 10 years ago. Surely the answer to sgccarey is:-
Right click on the array control or indicator and 'create local variable'
This variable will appear on the block diagram and can be set as 'Change to Write' or 'Change to Read' as necessary to use as the input and / or output array to a simple 'replace array subset'.
This way the array data only appears once on the Front Panel and is updated as required.
I have no idea if using Local Variables affects runtime efficiency but it works for me. Hope this helps.