Im new to VB and i have been reading alot into it.
I have come across 4 problems in which i have had trouble completing.
I have little idea of what is required but i dont know how to do it.
1) Design an algorithm to validate the data controls on the form and store the values into the appropriate variables converting the data type if necessary.
2) Design sample data sets that will test your algorithm and carry out a desk check.
3) When the algorithm checks out OK design VB code to implement the algorithm.
4) Add your code to the existing project code and test using the same data used to test the algorithm.
I will post what i have done but i need help with writing the algorithm. If anyone can help me i woul dreally appreciate it and will be very grateful for your help. Iv tried asking friends but they have no clue of coding. Please.
Are these question directed at me? or are they simplified questions of th equestions i posted. Anyway, i still dont know how to perform that. Can u please do a sample code or something and tell me how to implement it.
This should give you the basic idea. Command1 would be the button that gets things rolling, and it calls the validation function to see if it should proceed. The validation function checks a date field to see if it was empty, make sure it's a valid date, and makes sure the date isn't in the future.
What I would do would be to create a startup sub that abuses the form. Make a public function like "Execute" on the form that you can call from your sub.
VB Code:
'In Form1
Public Sub Execute()
Call Command1_Click
End Sub
'Startup Sub
Public Sub AbuseForm()
Dim fTarget As Form1, sValues() As String, lIndex As Long
Im sorry but i dont understand the coding. I need some to go through th ecoding step by step so i know what it is achieving. Please. I know im asking for alot of asistance but it is the only way i will learn. Thankyou.
Im sorry but i dont understand the coding. I need some to go through th ecoding step by step so i know what it is achieving. Please. I know im asking for alot of asistance but it is the only way i will learn. Thankyou.
No problem. I added comments to all of the code lines. This assumes that the form you are testing is Form1, with a textbox Text1 and a command button Command1.
VB Code:
Public Sub Execute() 'Public passthrough sub to simulate a button click.
Call Command1_Click 'Executes the button click code.
End Sub
'Startup Sub
Public Sub AbuseForm()
Dim fTarget As Form1, sValues() As String, lIndex As Long
sValues = Split("1/1/2006,kkkhh,,15/12/06,020205", ",") 'Create an array of test items.
For lIndex = LBound(sValues) To UBound(sValues) 'Loop through each item in the array.
Set fTarget = New Form1 'Create an instance of the target form.
fTarget.Show vbModeless 'Show it modeless (so it will run concurrently).
fTarget.Text1 = sValues(lIndex) 'Put the current test value into the textbox.
fTarget.Execute 'Call the button click pass-through.
Unload fTarget 'Unload the form (to reset values).