473,385 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

I want to make my function pause for a certain time (to display values in textbox)

I am facing an issue. Actually what i am doing is that i am tryin to store certain values in a database. A function is such that it calculates 5 values and stores them in a database. While storing them in the database it displays them in a textbox on the form. Now i want to display them one by one which it does. But it does it so fast that i can only see the last value that it enters in the database inside the textboxes.

Can i make it show all the values slowly one by one in the textboxes.

Can anybody suggest me how to do so. I googled a lot but could find a particular answer.
thnx in advance friends

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Sub CreateHash()
  3.         HashCalcProgressBar.Minimum = 0
  4.         HashCalcProgressBar.Maximum = 100
  5.         HashCalcProgressBar.Value = 0
  6.         HashCalcProgressBar.ForeColor = Color.Chocolate
  7.         Dim fileMD5 As String
  8.         Dim i As Integer
  9.  
  10.         ' for 32 bit use 
  11.         fileToHash(0) = "C:\Windows\system32\services.exe"
  12.         fileToHash(1) = "C:\Windows\system32\lsass.exe"
  13.         fileToHash(2) = "C:\Windows\system32\svchost.exe"
  14.         fileToHash(3) = "C:\Windows\system32\alg.exe"
  15.         fileToHash(4) = "C:\Windows\system32\winlogon.exe"
  16.  
  17.        For i = 0 To 4
  18.  
  19.             If HashCalcProgressBar.Value < 100 Then
  20.                 If My.Computer.FileSystem.FileExists(fileToHash(i)) Then
  21.                     'MsgBox("The File " + fileToHash(i) + " found in System Folder")
  22.                     fileMD5 = GenerateFileMD5(fileToHash(i))
  23.                     'MsgBox(fileMD5)
  24.                     dbInsert(fileMD5, fileToHash(i), i)
  25.                     HashCalcProgressBar.Value += 20
  26.                 Else
  27.                     MsgBox("File Not Found")
  28.                 End If
  29.             End If
  30.         Next
  31.         i = i + 1
  32.     End Sub
  33.  
  34.  
  35.     Private Sub dbInsert(ByVal strfile As String, ByVal hashoffile As String, ByVal p As Integer)
  36.         'parameter to the above function (ByVal strfile As String)
  37.  
  38.         DbConnection()
  39.         cmd = "select * from hashtable"
  40.         da = New OleDb.OleDbDataAdapter(cmd, con)
  41.         da.Fill(ds, "values")
  42.         maxrows = ds.Tables("values").Rows.Count
  43.         TextBox1.Text = p + 1
  44.         TextBox2.Text = hashoffile
  45.         TextBox3.Text = strfile
  46.         Dim cb As New OleDb.OleDbCommandBuilder(da)
  47.         Dim dsnewrow As DataRow
  48.         dsnewrow = ds.Tables("values").NewRow()
  49.         dsnewrow.Item("p_id") = TextBox1.Text
  50.         dsnewrow.Item("process_name") = TextBox2.Text
  51.         dsnewrow.Item("hash_value") = TextBox3.Text
  52.         ds.Tables("values").Rows().Add(dsnewrow)
  53.         da.Fill(ds)
  54.         da.Update(ds, "values")
  55.         'MsgBox("new Item added to database")
  56.         con.Close()
  57.     End Sub
  58.  
  59.     Private Sub btnHash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHash.Click
  60.         CreateHash()
  61.     End Sub
  62.  
Mar 8 '12 #1
1 1150
IronRazer
83 64KB
You could try putting a Threading.Thread.Sleep(ms) statement rite before the next statement in your for loop. There is one drawback to using it and that is that everything will be paused for the amount of time that the thread is sleeping for. I am not an expert so if anyone sees a problem with this please correct me. The only other way i know of is to rewrite parts of the program to use a timer.

This is your for loop with the Threading command :
Expand|Select|Wrap|Line Numbers
  1.         For i = 0 To 4
  2.  
  3.             If HashCalcProgressBar.Value < 100 Then
  4.                 If My.Computer.FileSystem.FileExists(fileToHash(i)) Then
  5.                     'MsgBox("The File " + fileToHash(i) + " found in System Folder")
  6.                     fileMD5 = GenerateFileMD5(fileToHash(i))
  7.                     'MsgBox(fileMD5)
  8.                     dbInsert(fileMD5, fileToHash(i), i)
  9.                     HashCalcProgressBar.Value += 20
  10.                 Else
  11.                     MsgBox("File Not Found")
  12.                 End If
  13.             End If
  14.             Threading.Thread.Sleep(1000)
  15.         Next
  16.         i = i + 1
  17.     End Sub
  18.  
The 1000 is the amount of time in milliseconds so 1000 would be 1 second, 2000 would be 2 seconds and so on.
Jan 19 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Matt | last post by:
Are there any settings to make a page invisible to the user until certain time? For example, I want mypage.html is invisible to the user until 12:00am. But mypage.html is already in the IIS server....
3
by: chuck | last post by:
Hi, This is a test for a larger form i am working on. I want to have a real time display of the radio button value when selected. I tried with various event handlers with varying success. The...
9
by: MLH | last post by:
I have a database (datatrek.mdb) with a table named DATA. The table has a date/time field with default value = Now(). It has 100 records in it entered over a 50-minute period. I would like the...
3
by: Marauderz | last post by:
Hello guys, got a little question regarding the regional language settings . Anyway I got a Windows 2003 Server machine that was installed with the date format "dd/MM/yyyy" and location still...
4
by: Tamer via DotNetMonster.com | last post by:
I'm developing a graphic engine. I got all equations made, I need only to understand how I can create a function that, once accepted three values (x; y; z), it returns the two values (X; Y) coming...
1
by: Eric | last post by:
Is it possible that in a continous form i create a listbox which is not a part of a table and disply some values. For eg: TableA has a field FieldA. I run a query on TableA when it loads it match...
4
by: eladla | last post by:
I have a windows service that I want to carry out an action on a certain day of the week at a certain time and if the time is missed for some reason, I want it to be carried out as soon as the...
4
by: joaotsetsemoita | last post by:
hello everyone. Im trying to time out a loot after a certain time. Probably 5 to 10 minutes. I have the following function Private Sub processFileCreation(ByVal source As Object, ByVal e As...
17
by: shivasusan | last post by:
Hi! In my program, I have multiple check boxs.(more the 10) But i give rights to select 2 check boxs, If i select more then 2 check boxs, I want to display alert message. Please any one post...
2
David Blackman
by: David Blackman | last post by:
I have a form with 4 unbound listboxes (LB). When the form opens, I want: 1. LB1 to display values in row 1; 2. LB3 to display data based on the value of LB1; 3. LB4 to display data based...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.