probleum in multiplication in vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • progvar
    New Member
    • Feb 2008
    • 40

    probleum in multiplication in vb.net

    i used the following code in vb 6.0 and it produced the required value
    but when i used the same code in vb.net it shows the error
    "Operator * is not defined for types Date and Integer"
    Dim Act_Rec As Integer
    Dim VTar_Hr As String
    Dim VYptime As String
    VTar_Hr=300
    VYptime="7:30:0 0"
    Act_Rec = CInt(VTar_Hr) * (CDate(VYptime) * 24)
    please help me

    with best regards
    varinder
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Varinder,

    What is it you are trying to acheive? I can't see why you would be multiplying a Date by an Integer but if you let us know we may be able to help.

    Incidentally, in VB.NET you can use

    Integer.Parse(V TAR_Hr) rather than CInt(VTar_Hr)

    and

    Date.Parse(VYpt ime) rather than (CDate(VYptime)

    Also the very useful TryParse function:

    If Integer.TryPars e(VTAR_Hr, Nothing) = True Then

    will come in handy for checking that your variables are of the correct type. Not relevant to your question exactly but useful to know :-)

    Regards,

    Dr B

    Comment

    • progvar
      New Member
      • Feb 2008
      • 40

      #3
      thanks Dr B
      Actually i want to find the average work of a person who entered 300 records in any database in one Hour .Then how many records would be entered in 7 hrs and 30 minutes

      this is my main motive

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        I've taken the number of hours and number of minutes from the Date variable and used them to calculate the total like this:

        Code:
         
        Dim iRec As Integer = 300
        Dim iTotal As Integer
        Dim dt As Date = "07:30"
        iTotal = (dt.Hour * iRec) + ((dt.Minute / 60) * iRec)
        Response.Write(iTotal)
        Hope this helps,

        Dr B

        Comment

        • progvar
          New Member
          • Feb 2008
          • 40

          #5
          thanks very much Dr B
          because this probleum was creating lot of trouble for me

          thanks again
          varinder

          Comment

          Working...