Pick a random name from a text file in VB - vb.net

I have a file that has names of competitors. I want to write a VB code that selects a random name from the file.What I need is show the names moving quickly once I press enter it will select the name. I hope you got the idea.

If i understand your problem correctly you want to show every names on the file to the user on a button which name is chances rapidly.
If you want to do this little trick you need to load all the names from the file at the begging and keep them in a array so you will not need to reconnect to the file, that contains your names, every time you change the name of the button
Once you get the names you will need to create an infinite loop and attach a timer so the loop will wait for a specific time to change the name of the button.
last thing that you need to do is write a set of code under the button. That breaks the loop and gives the name of the button which was the assigned name at the time of the clicking.
I hope that helps you!
Have a good day

Related

Why SeleniumIDE For Each loop uses one letter as local variable instead of whole word

I've tried SeleniumIde for first time few days ago and everyday been struggling a lot to just understand basic workflow however now I managed to login to webpage and store variable.
That variable, i wanted then to use as list.
The variable looks like this:
item1,item2,item3,item4
However, when use for each loop on this variable, it doesnt go item1>item2>item3, it goes i>t>e>m>1>i>t>e>m>2 etc. Either Selenium doesn't automatically parse it (make array from variable) as array, or im doing something wrong.
I'm sorry I have no clue how to import code from SeleniumIDE, therefore ill show screenshot.
https://i.imgur.com/0XaoanA.png
You can see on screen that I store variable, make foreach loop of it, and the loop writes one letter instead of one word in certain field on webpage.
Any help appreciated

VB.net - Search the whole registry for a value only?

So I'm trying to make a programm that searches the WHOLE registry for one specific value WITHOUT declaring the location of the key. It should just search for the value and print it in a msg box but the only way I found was to declare the location and search for the key then. The code should also take the value of a text box and search for this specific value. I don't really know what I could possible do next so I'm trying to get some help from you guys. If you have snippets, articels or smth like that pls send it 2 me :)

Moving the code one coloumn to the left

I wrote a code and now my excel template has changed (the first column is no longer in need), is there a way to move the entry code 1 column to the left instant of correcting it step by step?
For example(This is the old code):
.Range("I1:J1") = Array("CHECK", "KEY")
Now I need to change it to:
.Range("H1:I1") = Array("CHECK", "KEY")
But it's a very long code and I want to know if there's any way do to it easier.
Thanks.
I'd suggest simply using the built in Search & Replace function ( Ctrl + f ). Put something like
.Range("I1:J1")
into the "Find What" field and
.Range("H1:I1")
into the "Replace With" field.
If you're really lazy you could hit the Replace All button, but this can be dangerous as in possibly changing parts you didn't want to change. However, using the Replace button and going through all entries can be fairly fast even in a longer code, and this way you can check with each entry if it's really correct to change it.

How to select all instances of a variable and edit variable name in Sublime

If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:
Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?
Things I've Tried:
⌘D, ⌘K, and ⌘U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:
And using Ctrl⌘G simply selects all the string matches:
Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?
Put the cursor in the variable.
Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.
Press ⌘D as needed. Not on a Mac? Use CtrlD.
Didn't work? Try again, making sure to start with nothing selected.
More commands:
Find All: Ctrl⌘G selects all occurences at once. Not on a Mac? AltF3
Undo Selection: ⌘U steps backwards. Not on a Mac? CtrlU
Quick Skip Next: ⌘K⌘D skips the next occurence. Not on a Mac? CtrlKCtrlD
Sublime Docs
I know the question is about Macs, but I got here searching the answer for Ubuntu, so I guess my answer could be useful to someone.
Easy way to do it: AltF3.
Despite much effort, I have not found a built-in or plugin-assisted way to do what you're trying to do. I completely agree that it should be possible, as the program can distinguish foo from buffoon when you first highlight it, but no one seems to know a way of doing it.
However, here are some useful key combos for selecting words in Sublime Text 2:
Ctrl⌘G - selects all occurrences of the current word (AltF3 on Windows/Linux)
⌘D - selects the next instance of the current word (CtrlD)
⌘K,⌘D - skips the current instance and goes on to select the next one (CtrlK,CtrlD)
⌘U - "soft undo", moves back to the previous selection (CtrlU)
⌘E, ⌘H - uses the current selection as the "Find" field in Find and Replace (CtrlE,CtrlH)
This worked for me. Put your cursor at the beginning of the word you want to replace, then
CtrlK, CtrlD, CtrlD ...
That should select as many instances of the word as you like, then you can just type the replacement.
The Magic is, you have to start with an empty selection, so put your cursor in front of the word/character you want to multi-select and press Ctrl+D .
To me, this is the biggest mistake in Sublime. Alt+F3 is hard to reach/remember, and Ctrl+Shift+G makes no sense considering Ctrl+D is "add next instance to selection".
Add this to your User Key Bindings (Preferences > Key Bindings):
{ "keys": ["ctrl+shift+d"], "command": "find_all_under" },
Now you can highlight something, press Ctrl+Shift+D, and it will add every other instance in the file to the selection.
As user1767754 said, the key here is to not make any selection initially.
Just place the cursor inside the variable name, don't double click to select it. For single character variables, place the cursor at the front or end of the variable to not make any selection initially.
Now keep hitting Cmd+D for next variable selection or Ctrl+Cmd+G for selecting all variables at once. It will magically select only the variables.
It's mentioned by #watsonic that in Sublime Text 3 on macOS, starting with an empty selection, simply ⌃⌘G (AltF3 on Windows) does the trick, instead of ⌘D + ⌃⌘G in Sublime Text 2.
At this moment, 2020-10-17, if you select a text element and hit CTRL+SHIFT+ALT+M it will highlight every instance within the code chunk.
Just in case anyone else stumbled on this question while looking for a way to replace a string across multiple files, it is Command+Shift+F

Google Apps Script on Form Submit Time Formatting Glitch/Fix

Background:
How: I suspect that this is a glitch within Google Form (submission process)/Spreadsheet, but may be part of the Date conversion utility of the Spreadsheet interface (and is an intended feature).
When entering a format in a text box in Google Forms, there is some sort of communication error between the Form submit and Response Spreadsheet, or pre-processing of the Form's data before it is sent to the spreadsheet. The glitch only seems to happen for data in a text field of the format ##:## TEXT where TEXT contains no '.' characters. For example: 4:15 pm will reproduce the glitch, but 4:15 p.m and 4:15 p.m. will not.
Result: An apostrophe character is added to the beginning of the string when it is put into the Spreadsheet (i.e. '4:15 pm) which throws off several sub-systems I have in place that use that time data. Here are two screenshots (sorry for the bad sizing on the second):
I'm 99% certain that the glitch is caused by the ##: combination.
Temporary Fix?: The real question is... how might I go about removing that pesky apostrophe before I start manipulating the time data? I know how to getValue() of a cell/Range. Assume I have the value of a cell in the following manner:
var value = myRange.getValue();
// value = '4:15 pm
How can I go about processing that value into 4:15 pm? A simple java function could be
value = value.substring(1); // Assuming "value" is a String
But in Google App Scripts for Spreadsheets, I don't know how I would do that.
Post-Script: It is necessary to post-process this data so that I don't have to lecture university faculty in the language department about inputting time format correctly in their forms.
Thanks in advance to those who can help!
How can I go about processing that value into 4:15 pm? A simple java
function could be
value = value.substring(1); // Assuming "value" is a String But in
Google App Scripts for Spreadsheets, I don't know how I would do that.
Google Apps Scripts uses Javascript which has the exact same method.
value = value.substring(1);
should return all except the first character.
More about Javascript substring at: http://www.w3schools.com/jsref/jsref_substring.asp
If you remove the ' in the spreadsheet cell the spreadsheet interface will convert this entry to a date object.
This might (or not) be an issue for you so maybe you should handle this when you read back your data for another use...
It doesn't happen when text is different (for example with P.M) simply because in this case the ' is not necessary for the spreadsheet to keep it as a string since the spreadsheet can't convert it to a date object (time value).
Artificial intelligence has its bad sides ;-)
edit :
You cant do this in an onFormSubmit triggered function using the javascript substring() you mentioned. If you're not familiar with that, here is the way to go :
To run a script when a particular action is performed:
Open or a create a new Spreadsheet.
Click the Unsaved Spreadsheet dialog box and change the name.
Choose Tools > Script Editor and write the function you want to run.
Choose Resources > Current project's triggers. You see a panel with
the message No triggers set up. Click here to add one now.
Click the link.
Under Run, select the function you want executed by the trigger.
Under Events, select From Spreadsheet.
From the next drop-down list, select On open, On edit, or On form
submit.
Click Save.
see doc here and here