VB 2005 Newbie Questions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexandercowan
    New Member
    • Nov 2006
    • 2

    VB 2005 Newbie Questions

    Hi All,

    Sorry for these really pathetic questions, but I have been playing on VB 2005 today, and I am stumped.

    First question

    I have created a sub to calculate the difference in days of 2 datepickers and for the result to be displayed in a text box, but I cant get the result to display until I click in the text box and press a key...is there a way to generate the result without an event? The code I have used is as follows:

    Dim date1 As New Date
    Dim date2 As New Date
    Dim difference As TimeSpan

    date1 = DateTimePicker1 .Value
    date2 = DateTimePicker2 .Value

    difference = date1.Subtract( date2)

    textbox1.text = difference.tota ldays.

    Lastly (for now)

    I have created a combo box which contains 3 items, is there a way to get a result populated into a text box varying for each choice.

    For example

    First class (result in text box = £50.00)
    Second Class (result in text box = £60.00)

    Etc..

    Many thanks in advance.

    Alex
  • Taftheman
    New Member
    • Nov 2006
    • 93

    #2
    Originally posted by alexandercowan
    Hi All,

    Sorry for these really pathetic questions, but I have been playing on VB 2005 today, and I am stumped.

    First question

    I have created a sub to calculate the difference in days of 2 datepickers and for the result to be displayed in a text box, but I cant get the result to display until I click in the text box and press a key...is there a way to generate the result without an event? The code I have used is as follows:

    Dim date1 As New Date
    Dim date2 As New Date
    Dim difference As TimeSpan

    date1 = DateTimePicker1 .Value
    date2 = DateTimePicker2 .Value

    difference = date1.Subtract( date2)

    textbox1.text = difference.tota ldays.

    Lastly (for now)

    I have created a combo box which contains 3 items, is there a way to get a result populated into a text box varying for each choice.

    For example

    First class (result in text box = £50.00)
    Second Class (result in text box = £60.00)

    Etc..

    Many thanks in advance.

    Alex
    Firstly try refreshing your text box

    textbox1.refres h

    and

    try adding indexs to the combo box

    Comment

    • alexandercowan
      New Member
      • Nov 2006
      • 2

      #3
      Originally posted by Taftheman
      Firstly try refreshing your text box

      textbox1.refres h

      and

      try adding indexs to the combo box

      hi, thanks for your response, how would i add indexes to the combo box?

      Comment

      Working...