pictures keep changing on the form, there should be at least 5 pictures on every different groupbox using loop - vb.net

I want a way of loading 5 pictures on every refresh. i have over 300 pictures in the database and i want them to load every 5 picture on form load. and then they sray there for 10sec and then the next 5 loads n keeps loading till al the pictures are loaded then it restarts again from the start.
it should be using a loop. because i have a dynamic way of loading my pictures and textboxes. so how could i jst load 5 pictured and then the next 5 after the first 5 have disappeared. all should happen on one form. maybe even use ashock.. or any other way.

or any other way.
you can do like this, First get all those 300 pictures in the load event and store that in a datatable (using datatable will shrinks the possibility to connect to back end multiple times).Then use a timer in your form and set its interval for 5000 ms(i.e 5 seconds). use a global variable to to track how many pictures are shown, increment it by 5 for every tick event's call(Tick event will get fired when interval assigned by you gets elapsed. - ex: for every 5 seconds). now inside the tick event, get five pictures from the datatable(use that global variable to get the next 5 images). Display those five images by replacing the old ones.and once that global variable reaches 300 again reset it to 0. This cycle will ends only if you stop the timer.
Hope this will give you an idea to accompolish your task.

Related

Is the saving time of record proportional to the number of item lines in NetSuite?

I have a SO with 500 item lines.
Once I click the "Save" button, the following code will execute and it may spend about 90 to 120 seconds to finish saving:
var so_submit_id = so_record.save({
// enableSourcing: true,
// ignoreMandatoryFields: false
});
I found the more item lines, the longer time the record is saved.
Is the saving time is proportional to the number of item lines? Is there a linear relationship which the time complexity is O(n) between them?
How can we reduce the record saving time? Can we divide the record to update the values and finally merge the child records?
Under Customisation>Scripting>Scripted Records, how many scripts are running for your record type?
Based on that, you can get results for your "Performance Details" by double clicking on the Oracle | NetSuite logo on the top left of the UI. This will prompt a dialogue box depicting what, and how long things took. A few tests on the number of lines and you can plot a curve for your system.
Hope this added value for the testing!

vb.net program to register time on multiple runners

I building a program to track the time of up to 60 runners. My idea is to use a DataGridView with columns for:
ID (DataGridViewTextBoxColumn)
Name (DataGridViewTextBoxColumn)
Start time (DataGridViewButtonColumn)
Stop time (DataGridViewButtonColumn)
Reset time (DataGridViewButtonColumn)
Finish time (DataGridViewTextBoxColumn)
Adding columns 1-5 including functions is no problem, but I cannot wrap my head around how to display a stopwatch in column 6.
My idea was to add a timer and stopwatch function every time a new row I added, but do I need a timer for each row? If so how do I set the ID of that timer, so I can call the Tick event and display the time in column 6?
Also I assume that I need a stopwatch for each row? So how do I set the name of ID of each Stopwatch - can seem to find any property for that?
See below screen shot of what I am trying to accomplish.
Thanks in advance.
Screen shot

Loading items in Combobox

I am working on a project and the problem that I have is; the items of my combobox are being loaded from the database table(one field); the table has more than 1000 records:
how can I load these records(one field) as items by giving a limit of 50 while allowing the user who wants to see all of the records through the combobox to see them but still by a group of 50?
which event can be the best for loading items to the combobox? textchanged, click....
I was thinking to use the vertical scroll bar so that when the user is at the end of the displayed items the next 50 will be loaded and if he is on the first and scrolls up the previous 50 will be loaded:problems with this way of thinking are:
when the user typed some caracter from the word that he wanna select
from the items' list if it is not loaded yet from the DB he will be
obliged to type the whole word
I don't know which event is raised
when scroll bar of reaches the end or is at the beginning
Is there any other way to do that?

Not understanding control removal from panel

I have a panel with about six controls on the panel. I wanted to remove the controls from the panel and finally did so with MyPanel.Clear(). But before that I tried the following code that runs from a button click:
For Each b As Control In MyItem.MyPanel.Controls
MyItem.MyPanel.Controls.Remove(b)
Next
I would click the button and watch it, as well as the MyItem.MyPanel.Controls.Count in debug. As it went through, the count would reduce: to 5 to 4 to 3, then it would exit. If I clicked the button again it would remove two more, then the last one on the third click, so they all fit the bill and were all removed without changing anything. Why did it take three clicks? I'm obviously missing something simple here, I think, but I don't know what it is, and I'd really like to understand it. If I had to remove specific controls, it looks like I would have had a problem.
I ran into this issue myself and its odd it even lets you do it as you're modifying the collection in the loop you are referring to.This should be a better method.
If you like to remove them based on type
For i = Panel1.Controls.Count - 1 To 0 Step -1
If TypeOf Panel1.Controls(i) Is Label Then
Panel1.Controls.Remove(Panel1.Controls(i))
End If
Next
Odd that VB.NET even lets you do this, but essentially what you are doing is editing the collection you are iterating through. To better understand, pretend you are using a regular for loop from 1 to 6, at the first iteration you are removing object 1, leaving you with 5 objects, making the old number 2 object the first. The next iteration you remove the 2nd thing, which used to be the third, and so on. Most languages this is a run-time error.
What is happening is that you are deleting the controls starting from the first position and moving to the last. If the list has 6 records and you start deleting them like you are, programatically you are saying:
remove(0)
remove(1)
...
remove(5)
While you are doing that, the list is getting smaller. Once you delete the first item it drops from 6 positions to 5, then 4, then 3, etc. So midway through your code it tries to remove item at location 3 (4th item), but since you already removed 3 items, the list's size only contains 3 items and that position does not exist.
To properly remove them all, you would have to start at the back of the list and move to the front.
Perhaps something like:
For i As Integer = (MyItem.MyPanel.Controls.Count- 1) To 0 Step -1
MyItem.mypanel.Controls(i).Dispose()
Next

VB.net Game Using Picture Boxes Functions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to develop a simple game using picture boxes
For example, if you have 3 different picture boxes each containing a unique picture
When a form loads, one box is visible while other two are invisible
The player has to click on the visible picture box before it becomes invisible (time is specified for the box to stay visible)
Example: box 1 stays visible for 5 seconds , if the box is not clicked during the 5 seconds box 1 become invisible , and another random box will become visible.
Of course , if the user click on the picture successfully his score is updated
Different levels can be made by making the time shorter
The code would probably be one single code placed at the form load
Any help? Thanks
I would probably use a stopwatch - a timer would be difficult because i dont know of a way to reset the count back to 0 when a user clicks sucessfully.
declare a stopwatch like so:
Private maxWaitTimer As New Stopwatch
then, perhaps a 'game loop' type of thing could be used in your form load event... maybe something like this:
maxWaitStopwatch.Start()
While(GameIsRunning)
If maxWaitStopwatch.ElapsedMilliseconds > 5000 Then
Losses = Losses + 1
selectNewPictureBox()
maxWaitStopwatch.Restart()
Else
Application.DoEvents() 'this gives the program a chance to execute the picture box click event, among other things (resize, drag, etc... since we are spinning in a loop)
End If
'System.Threading.Thread.Sleep(100) 'uncommenting this line will prevent it from maxing out your processor, although it will be slightly less responsive
End While
and your picture boxes could implement something like this:
Wins = Wins + 1
selectNewPictureBox()
maxWaitStopwatch.Restart()
basically, your program spins around in a loop, checking to see if the timer is elapsed, and if it is, it moves the picture.
the click event increments the score - it has a chance to be run during the 'application.doevents()' portion of the loop.
adding a sleep(100) will slow it down very slightly (and make it slightly more innaccurate, by about 100ms), but it will prevent it from using tons of CPU. you probably wont notice the difference in speed.
there may be better ways to do this, though...
EDIT - reflecting what steven said, it would be better if you used a timer instead of a loop:
use stop() when the user clicks the picture, and then call start() after.
(i didnt realize that would reset it, but apparently it does)
Use a timer with an interval of 5000 and then in the elapsed event handler
Timer.stop()
Losses = Losses + 1
selectNewPictureBox()
Time.start()
Then in the picture box handler
Timer.stop()
Wins = Wins + 1
selectNewPictureBox()
Timer.start()