Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi.

 

I have this function for loading several files starting from current day.

 

Public Sub grafic_for(ByVal x, ByVal y, ByVal y1)

       'cur_day.Text = ziua
       'cur_month.Text = month
       'cur_year.Text = year

       For i As Integer = 0 To x


           ziua = Format(DatTim1.AddDays(-i), "dd")
           month = Format(DatTim1.AddDays(-i), "MM")
           year = Format(DatTim1.AddDays(-i), "yyyy")

           cale_finala = cale + ziua + month + year + ext

           Dim my As IO.StreamReader
           check_file(cale_finala)

           my = IO.File.OpenText(cale_finala)
           Dim Line As Object
           Dim space1 As Object = "	"
           Dim enter1 As Object

           Line = my.ReadToEnd
           my.Close()
           info = Line.split(space1)

           For k As Integer = y To y1
               info_total(i, k) = info(k)
           Next

       Next


   End Sub

 

The problem is that I put some textbox�s to input the data for loading those files.

 

Ex: if today is 02.12.2003 and I want the last 3 days, my function will load 02122003.txt, 01122003.txt and 30122003.txt.

 

But I want to input the starting day from textbox�s.

 

Ex: Even if current day is 02.12.2003 and I put in that textbox�s 05 11 2002 I want to load 05112002.txt, 04112002.txt and 03112002.txt.

 

Don�t know what to do here, because I get all kind of errors when I�m trying different things.

 

All I want is to change the current time with the textbox's values.

 

thanks

Edited by Ace Master
Posted

DateTimePicker Control

 

Can't you use a DateTimePicker Control to read the date in to a string variable and then format the string as you like it ?

 

Cire

Trust the Universe
Posted

I have now something like that. To read from textbox as the current time, but I want to make adddays(-i) and this is not posible to a string, only a date variable.

 

Today is 02 dec. If a have a string value or integer and I want to see the file from 4 days a go....I will have -2 value.

 

I need date value for receiving 29 nov.

 

All I want is to convert for ex. 02 to a date value (day) for make days substractions. The same with "11" to month value and year.

Posted

You could try using CType. You'd have to make sure the text in the textbox if formatted right but you should be able to do something like this:

 


Dim myDate As Date

myDate = CType(txtYourTextBox.Text, Date)

 

Again, you'll have to make sure the text in the textbox is formatted in such a way that it will work as a Date type but, that should work. I do think that using a DateTimePicker is a better idea though, that way you're not switching types all over the place and there's less chane for problems.

Being smarter than you look is always better than looking smarter than you are.
Posted
If you're using a DateTimePicker control, you won't neet to convert anything. Just use the .DateValue of the picker control and it's already a Date type. If you need specific times as well as dates, you could also use a second picker and have the user select the time.
Being smarter than you look is always better than looking smarter than you are.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...