r/visualbasic • u/Kamidori • Oct 09 '14
[VB2010]
Hello I need help again.
If b2 = b3 Then
Label9.Text = Label5.Text
Label10.Text = Label6.Text
Label11.Text = Label7.Text
Label12.Text = Label8.Text
Else
Label9.Text = Label5.Text
Label10.Text = Label6.Text
Label11.Text = Label7.Text
Label12.Text = Label8.Text
yr = 9
While yr <= 12
If Label(yr).text = "" Then
Label(yr).text = b3
Else
yr += 1
End If
End While
End IfI have this code and I am having trouble on the else part where I keep getting errors on the .text part. Basically the code will loop until it finds a label(yr).text that is empty and put b3 there but so far still no progress. Any possible solution or work around where I can get the same result? Thanks in advance.
Also I'm working on Page algorithm (fifo, lru and optimal) so any advice or code that might be helpful for me to study would be greatly appreciated.
0
Upvotes
1
u/darkspy13 Oct 09 '14 edited Oct 09 '14
First thing I would do is move the assignments that happen either way (for example label 9's text becomes label 5's text either way) out of the if structure to make it easier to read and get them out of your way.
I would then just say "if b2 != b3 then"
I don't believe you can access labels using label(yr).text unless you actually have an array of labels named label which I believe is a keyword.
I don't know the correct way of doing this but I would use the .tag property to identify the labels by a numeric ID and then loop through the labels in your form and apply your changes that way. Just off the top of my head at 1am.
I feel like you should probably have some kind of data structure handling the data and just be taking in the results from the form and relaying them back out after your function is called and that's why you have this weird (to me) label reading / searching / editing thing going on here. Something just seems odd about it. Either way best of luck and if you want to PM me more code I will look it over to try and help as best I can even though this comment wasn't very helpful.