![]() ![]() You can also use do from thing like: do while var=10 this will only do the commands if var is equal to 10! That's all for the Not So Basics of vbs. do until var=5 but in the code you must make it add 1 or more to the var. ![]() You can always add a Until on the do or on the loop part. say if you wanted to keep saying a message until a certain option is picked. mainly used for viruses =P but you can use them to help you. Do, Loop the do loop is used to loop a piece of code over and over and over ect. ![]() in this case the message will only show twice because 5 is the limit. to the end of for var = 0 to 5 e.g for var = 0 to 5 step 5 that will make it jump 5 each time. For, Next, Do, Loop The For, Next loop can be used to repeat things, for example: for var = 0 to 5 msgbox(var) next msgbox("Finish") This will pop up a message box counting 0,1,2,3,4,5 then it will say 'Finish' REMEMBER in vbs 0 nearly always counts! so that code would repeat a command 6 times e.g: for var = 0 to 5 msgbox("hello") next msgbox("Finish") the message 'hello' would come up 6 times. result = time(10,10) this went to the function times x is now 10 and y is now 10 so: x * y return value with answer. Lets start with an easy function: (pic 1) Function times(x,y) times = x * y End Function Dim result dim var1 result = times(10,10) var1=msgbox(result) This would give you 100 let me explain. even though they are quite easy =P functions in vbs are easy. I'm going to start this step with Functions. Subs You can also have subs: A sub is a procedure that does NOT give a return value. you could have: (pic 2) dim iRule dim instructables iRule="instructables" instructables=msgbox("hello " & iRule) Because of the & it says 'hello instructables' becuse the value of iRule is instructables. Also with vars you can dim vars in an array: dim iRule(3) but that would turn out like this: (because 0 is included) iRule(0)="var1" iRule(1)="var2" iRule(2)="var3" iRule(3)="var4" Using vars in the script. here is all about message boxes: HERE so many tutorials on them that i won't even bother to go into them. (pic 1) Along with that you can add different buttons to the message box. like: iRule=msgbox("hello") this would make a message box pop up saying hello. dim iRule now you would have a variable call iRule now you can start to add things to you vars. But at the same time it's nothing like it. vbs It's not like a batch file it doesn't have a screen telling you information. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |