marymary23

good morning

first, let there is some textbox enterd with time like this"09:15" how can i get 09 and 15 each alone(each one in different register)

second is not on this post, its about progress bar. i dont know how can i link between some progress and the bar

wait answer from you

have a good day

mary



Re: Visual Basic Language progress bar and separate textbox

dvkCH

Hello.

I didn't understand your fisrt question, so i'll answer the second with an exemple :

You have a DownloadClass which have properties such as .TotalSize, .Downloaded, .ElapsedTime , etc

You also have a progressbar (ProgressBar1) on your form. To display the progression of your download simply add a timer, which tick every second (for exemple) and do this :

Code Snippet

Public Class Form2

Dim DL As New MyDownloadClass

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Me.ProgressBar1.Minimum = 0

Me.ProgressBar1.Maximum = DL.TotalSize

Me.ProgressBar1.Value = DL.Downloaded

End Sub

End Class






Re: Visual Basic Language progress bar and separate textbox

marymary23

hi dvkCH

i have textbox1,the user enter this value "0915" which mean 9 oclock and quarter.
now ,i want to print 09 on line
and 15 on other line
about the progress bar,i will try it
thank you




Re: Visual Basic Language progress bar and separate textbox

marymary23

please answer me, its urgent




Re: Visual Basic Language progress bar and separate textbox

dvkCH

Hello,

Sorry to be late, I didn't see your answer. If I understand right your question : you have (on a form) a TextBox which only purpose is to get time entered by the user, and then you want to split it to have hours and minutes separated.
Well, this code may help you (and I hope)

Code Snippet

Private Sub z_Button1_Click( [...] ) Handles z_Button1.Click

Dim n_Hours As Integer

Dim n_Minutes As Integer

'Used to determine how the user entered the time.

Select Case (True)

Case z_TextBox1.Text.Contains(":")

'HH:MM (or H:MM)

n_Hours = z_TextBox1.Text.Split(":")(0) ' before ":"

n_Minutes = z_TextBox1.Text.Split(":")(1) ' after ":"

Case z_TextBox1.Text.Length = 4 And Not z_TextBox1.Text.Contains(":")

'HHMM and not H:MM

n_Hours = z_TextBox1.Text.Substring(0, 2) ' first 2characters : HH

n_Minutes = z_TextBox1.Text.Substring(2, 2) ' last 2characters : MM

Case z_TextBox1.Text.Length = 3

'HMM

n_Hours = z_TextBox1.Text.Substring(0, 1) ' first character : H

n_Minutes = z_TextBox1.Text.Substring(1, 2) ' last 2characters : MM

Case Else

MsgBox("An error occured, contact the software developper ASAP !")

End Select

End Sub

These few lines :

-determine wheather if the user entered the time in one of these three formats : HH:MM , H:MM , HHMM or HMM

-split it on two parts : Hours / Minutes

-advert the user if he didn't type the time correctly.

Hope it'll help you.

You also can contact me by Msnm when you want with the following address : develop2k[at]gmail[dot]com.






Re: Visual Basic Language progress bar and separate textbox

marymary23

hi dvkCH
thank you ,its work!!great
but still dont know what to do with progress bar but i saw
rkimble answer here:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1982250&SiteID=1
and i will try it

other small point can i prevent entering char.

regards,
mary




Re: Visual Basic Language progress bar and separate textbox

dvkCH

marymary23 says :

"but still dont know what to do with progress bar"

what do you really want to do

There are two way to prevent entering char :

Fisrt one :

you can disable temporarly the TextBox :

Code Snippet

TextBox1.Enabled = False

But you also can capture the "TextChanged" event to put the old value in the textbox. (don't have time to put code sample) .




Re: Visual Basic Language progress bar and separate textbox

Ben-C

If all you are trying to do is allow the user to enter a time, it may be better to use the DateTimePicker instead.

Drag an instance of the DateTimePicker on to your form.
Now set the 'Format' property to 'Time'.

This turns it into a Time picker.

Benefit being, you don't have to parse data provided by the user. User simply can not select or enter invalid data.

Then just use the Value property at runtime to get the selected value as a DateTime instance, and use the Hours and Minutes properties of that as required.






Re: Visual Basic Language progress bar and separate textbox

marymary23

thank you