Reset Sript values

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
tcollins
Posts: 3
Last visit: Tue Aug 07, 2012 7:06 am

Reset Sript values

Post by tcollins »

Hi, I am relatively new to VBScript. I have done some in university however, it has been some time. I will try to explain what I am trying to perform to give some context. I am creating a field inspection form using a GIS (Global Information Systems) software package ArcPAD (basically a geographical database). I have created a form that would simplifiy the inspectors life by creating a main catagory question. For example one catagory is "Pole Maintenance" The question asks "Does this pole require maintenance?" [yes/no] or [1/0]. If the answer is "no" or 0 then the script hides the following questions in the catagory and populates all the questions in that catagory with a no or 0. If "yes" 1 then the user must specify the problem by answering the remainder of the questions in the catagory. This script is called by a "onselchange" event for the initial catagory question. My script works if you select "No" then the fields are hidden and populated, however, if I change from a No to a yes then the form is not reset. Can anyone see what is wrong with the script below? Thanks!! Tim Sub Fields Dim objPoleMaint Set objPoleMaint = ThisEvent.Object Dim PoleMaint Set PoleMaint = objPoleMaint.Parent Dim objBroken Set objBroken = PoleMaint.Controls("objBroken") Dim objScaling Set objScaling = PoleMaint.Controls("objScaling") Dim objCrossArms Set objCrossArms = PoleMaint.Controls("objCrossArms") Dim objGuyStrain Set objGuyStrain = PoleMaint.Controls("objGuyStrain") Dim objGuyGuard Set objGuyGuard = PoleMaint.Controls("objGuyGuard") Dim objGrading Set objGrading = PoleMaint.Controls("objGrading") Dim objBurning Set objBurning = PoleMaint.Controls("objBurning") Dim objPolePriority Set objPolePriority = PoleMaint.Controls("objPolePriority") Dim txtbox1 Set txtbox1 = PoleMaint.Controls("txtBroken") Dim txtbox2 Set txtbox2 = PoleMaint.Controls("txtScaling") Dim txtbox3 Set txtbox3 = PoleMaint.Controls("txtCrossArms") Dim txtbox4 Set txtbox4 = PoleMaint.Controls("txtGuyStrain") Dim txtbox5 Set txtbox5 = PoleMaint.Controls("txtGuyGuard") Dim txtbox6 Set txtbox6 = PoleMaint.Controls("txtGrading") Dim txtbox7 Set txtbox7 = PoleMaint.Controls("txtBurning") Dim txtbox8 Set txtbox8 = PoleMaint.Controls("txtPolePriority") Select Case objPoleMaint ' When the main catagory question is answered no, then the remaining questions are made invisible and populated with a 0 value Case 0 objBroken.Visible = false objScaling.Visible = false objCrossArms.Visible = false objGuyStrain.Visible = false objGuyGuard.Visible = false objGrading.Visible = false objBurning.Visible = false objPolePriority.Visible = false objBroken.Value = 0 objScaling.Value = 0 objCrossArms.Value = 0 objGuyStrain.Value = 0 objGuyGuard.Value = 0 objGrading.Value = 0 objBurning.Value = 0 objPolePriority.Value = 0 txtbox1.Visible = false txtbox2.Visible = false txtbox3.Visible = false txtbox4.Visible = false txtbox5.Visible = false txtbox6.Visible = false txtbox7.Visible = false txtbox8.Visible = false Case 1 objBroken.Enabled = true objScaling.Enabled = true objCrossArms.Enabled = true objGuyStrain.Enabled = true objGuyGuard.Enabled = true objGrading.Enabled = true objBurning.Enabled = true objPolePriority.Enabled = true End Select Set objBroken = Nothing Set objScaling = Nothing Set objCrossArms = Nothing Set objGuyStrain = Nothing Set objGuyGuard = Nothing Set objGrading = Nothing Set objBurning = Nothing Set objPolePriority = Nothing End Sub
User avatar
tcollins
Posts: 3
Last visit: Tue Aug 07, 2012 7:06 am

Reset Sript values

Post by tcollins »

Hi, I am relatively new to VBScript. I have done some in university however, it has been some time. I will try to explain what I am trying to perform to give some context. I am creating a field inspection form using a GIS (Global Information Systems) software package ArcPAD (basically a geographical database). I have created a form that would simplifiy the inspectors life by creating a main catagory question. For example one catagory is "Pole Maintenance" The question asks "Does this pole require maintenance?" [yes/no] or [1/0]. If the answer is "no" or 0 then the script hides the following questions in the catagory and populates all the questions in that catagory with a no or 0. If "yes" 1 then the user must specify the problem by answering the remainder of the questions in the catagory. This script is called by a "onselchange" event for the initial catagory question. My script works if you select "No" then the fields are hidden and populated, however, if I change from a No to a yes then the form is not reset. Can anyone see what is wrong with the script below? Thanks!! Tim Sub Fields Dim objPoleMaint Set objPoleMaint = ThisEvent.Object Dim PoleMaint Set PoleMaint = objPoleMaint.Parent Dim objBroken Set objBroken = PoleMaint.Controls("objBroken") Dim objScaling Set objScaling = PoleMaint.Controls("objScaling") Dim objCrossArms Set objCrossArms = PoleMaint.Controls("objCrossArms") Dim objGuyStrain Set objGuyStrain = PoleMaint.Controls("objGuyStrain") Dim objGuyGuard Set objGuyGuard = PoleMaint.Controls("objGuyGuard") Dim objGrading Set objGrading = PoleMaint.Controls("objGrading") Dim objBurning Set objBurning = PoleMaint.Controls("objBurning") Dim objPolePriority Set objPolePriority = PoleMaint.Controls("objPolePriority") Dim txtbox1 Set txtbox1 = PoleMaint.Controls("txtBroken") Dim txtbox2 Set txtbox2 = PoleMaint.Controls("txtScaling") Dim txtbox3 Set txtbox3 = PoleMaint.Controls("txtCrossArms") Dim txtbox4 Set txtbox4 = PoleMaint.Controls("txtGuyStrain") Dim txtbox5 Set txtbox5 = PoleMaint.Controls("txtGuyGuard") Dim txtbox6 Set txtbox6 = PoleMaint.Controls("txtGrading") Dim txtbox7 Set txtbox7 = PoleMaint.Controls("txtBurning") Dim txtbox8 Set txtbox8 = PoleMaint.Controls("txtPolePriority") Select Case objPoleMaint ' When the main catagory question is answered no, then the remaining questions are made invisible and populated with a 0 value Case 0 objBroken.Visible = false objScaling.Visible = false objCrossArms.Visible = false objGuyStrain.Visible = false objGuyGuard.Visible = false objGrading.Visible = false objBurning.Visible = false objPolePriority.Visible = false objBroken.Value = 0 objScaling.Value = 0 objCrossArms.Value = 0 objGuyStrain.Value = 0 objGuyGuard.Value = 0 objGrading.Value = 0 objBurning.Value = 0 objPolePriority.Value = 0 txtbox1.Visible = false txtbox2.Visible = false txtbox3.Visible = false txtbox4.Visible = false txtbox5.Visible = false txtbox6.Visible = false txtbox7.Visible = false txtbox8.Visible = false Case 1 objBroken.Enabled = true objScaling.Enabled = true objCrossArms.Enabled = true objGuyStrain.Enabled = true objGuyGuard.Enabled = true objGrading.Enabled = true objBurning.Enabled = true objPolePriority.Enabled = true End Select Set objBroken = Nothing Set objScaling = Nothing Set objCrossArms = Nothing Set objGuyStrain = Nothing Set objGuyGuard = Nothing Set objGrading = Nothing Set objBurning = Nothing Set objPolePriority = Nothing End Sub
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Reset Sript values

Post by jvierra »

What form? I see no form. There are only objects.

If this is an HTA then your approach is archaic. Yo are doing way more work than necessary.

Hierarchical questionairs are bes t driven from a data sourcxe that can act as a linked list with various options. We gnerally generate teh form dirstly off of this list. Yu see these questioainrs all of the time on the Internet. You see one every time yuo anser a questionaire abut a site or a product. We use them to gather patirnt infomation for mediacla fors.

Q,prompt,choices, next
1,What is your age", Int(answer).2
2.What is your gender,choice(m,f),opt(3,4)
3,<path for male questions>....
4, <path for female questiosn>...

This textual representation can be esaily designed in an Excel spreadsheet. We thne just read it into teh script and generate the sessions. We can use prop=mpts like listbox(choice , choice b, chioce c)) or a declaration of other types of controls that our script will create for us.


jvierra2012-08-07 13:55:56
User avatar
tcollins
Posts: 3
Last visit: Tue Aug 07, 2012 7:06 am

Reset Sript values

Post by tcollins »

This is the form. I my terminology may not be correct. However, The text questions are texbox1-6. The drop down fields are my obj* they are domained field with with yes/no as the only options. The script is called when making a change in the "Does this pole require maintenance field?"
This topic is 11 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked