12 Replies - 987 Views - Last Post: 27 July 2012 - 03:02 AM Rate Topic: -----

#1 Khanya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-June 12

If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 12:55 PM

Hello all. New to the forums, and also a newbie in VB.NET and programming.

Wondering if I can get aid in my dilemma; this app of mine I want it to display a string I've predefined in my code.

So inherently each day, a new text appears on the UI, next day something I've predefined appears etc. Each day a new variable (string) appears for the user.

I solely have no clue how to go about doing this, any help would be appreciated.


Thank you in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: If date = dd/mm/yyyy then display myVariable (string)

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 02:15 PM

Where are you storing your strings?
Was This Post Helpful? 0
  • +
  • -

#3 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 02:16 PM

Hey welcome to dreamincode.

I am confused as to what it is that you are trying to do. Can you try to explain in more detail
Was This Post Helpful? 0
  • +
  • -

#4 Khanya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-June 12

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 02:31 PM

View Postm_wylie85, on 04 June 2012 - 11:16 PM, said:

Hey welcome to dreamincode.

I am confused as to what it is that you are trying to do. Can you try to explain in more detail


Hi. Say to dissect it. The application has form1, on form1 say I have a string variable named foursix12 (this is a date: 4/6/12)that will display on textbox1; alright that's fine, but tomorrow I want to display fivesix12 on textbox1 and sixsix12 on textbox1 the day after. Like a "displaying the 'quote of the day'" kinda thing.

View PostBobRodes, on 04 June 2012 - 11:15 PM, said:

Where are you storing your strings?


In my code editor along with the rest of my code.
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 02:43 PM

You'll want to become more familiar with arrays. This is pretty simple to do with an array. Just put all your strings into an array, and use the current date to figure out which array element to access.
Was This Post Helpful? 0
  • +
  • -

#6 Khanya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-June 12

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 02:46 PM

View PostBobRodes, on 04 June 2012 - 11:43 PM, said:

You'll want to become more familiar with arrays. This is pretty simple to do with an array. Just put all your strings into an array, and use the current date to figure out which array element to access.


OK; thanks let me take a profound ponder over that...

Will report later.
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 04 June 2012 - 02:47 PM

That's the spirit. :) Post back with questions if you get stuck.

This post has been edited by BobRodes: 04 June 2012 - 02:48 PM

Was This Post Helpful? 0
  • +
  • -

#8 PNJLj  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 180
  • Joined: 18-May 09

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 06 June 2012 - 02:46 AM

you could use "Date Time Picker" instead. and try doing the date like this

 textbox1.text = date.now.toshortdatestring 


and then do an If statement later to determine when to put in the other date.
Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#9 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 06 June 2012 - 06:55 AM

You could use a date time picker if you wanted the user to select a date and time, but (if I understand his requirements correctly) that isn't what the OP asked to do. He wants to evaluate the current date, and display a string based on that date. The user isn't involved in picking the date.

This post has been edited by BobRodes: 06 June 2012 - 06:57 AM

Was This Post Helpful? 0
  • +
  • -

#10 Khanya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-June 12

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 06 June 2012 - 10:19 AM

View PostPNJLj, on 06 June 2012 - 11:46 AM, said:

you could use "Date Time Picker" instead. and try doing the date like this

 textbox1.text = date.now.toshortdatestring 


and then do an If statement later to determine when to put in the other date.
Hope this helps.

That could be an additional feature, which would allow the user to select a previous date and display the string.

View PostBobRodes, on 06 June 2012 - 03:55 PM, said:

You could use a date time picker if you wanted the user to select a date and time, but (if I understand his requirements correctly) that isn't what the OP asked to do. He wants to evaluate the current date, and display a string based on that date. The user isn't involved in picking the date.


Exactly the latter. I want to display a new string daily (at 00:00). I'll store the strings internally. How to do it; kinda trying it out.
Was This Post Helpful? 0
  • +
  • -

#11 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 06 June 2012 - 06:48 PM

Arrays.... :) Let me know if you get stuck in your ponderings.
Was This Post Helpful? 0
  • +
  • -

#12 Khanya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-June 12

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 27 July 2012 - 02:29 AM

Hey guys thanks, my program works fully, I'm adding extensions to it.

I used

If Date.Today <= CDate(2012/06/26) Then 'Date of program inception
RichtextBox1.Text = "Oops! Your date is probably wrong! Check your date settings."
RichtextBox2.Text = "Oops! Your date is probably wrong! Check your date settings."
MessageBox.Show("Oops! Your date is probably wrong! Click OK for instructions")


If Date.Today = CDate(2012/07/27) Then
RichtextBox1.Text = Quote(71)
RichTextBox.LoadFile("C:\MyApp\20120727", RichTextBoxStreamType.PlainText)


If Date.Today >= CDate(2013/01/01) Then
RichtextBox1.Text = "Upgrade your software! Click OK for instructions"
RichTextBox.Text = "Upgrade your software! Please contact xxx"

Was This Post Helpful? 0
  • +
  • -

#13 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: If date = dd/mm/yyyy then display myVariable (string)

Posted 27 July 2012 - 03:02 AM

If Date.Today >= CDate(2013/01/01) Then



You are aware that this while do, the two divisions before converting to to a date.

vb.net does support americanised date literals.
' Americanised Date Format is used MM/DD/YYYY'
If Date.Today >= #01/01/2012# Then 


This post has been edited by AdamSpeight2008: 27 July 2012 - 03:09 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1