[RESOLVED] Astrological Calculations
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: [RESOLVED] Astrological Calculations

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    59

    [RESOLVED] Astrological Calculations

    Name:  1.jpg
Views: 79
Size:  21.1 KB
    Name:  2.jpg
Views: 72
Size:  31.1 KB

    Witch code must be writen in order to show this:

    Already i have 8 textbox, 1 label and1 command button. I add second label and name itZdate. Now i want when i put number in days and months field on Zdate label it show zodiac name. For example:
    Code:
     If Text5, text6, text7, text8 = "from 03 - 21 to 04-20" then
    Zdate.caption = "Aries"
    Else
    EndIf
    End Sub
    I hope you understand what i wanna to do

    Zodiac date table:

    Aries - 03.21-04.20
    Ox - 04.21-05.21
    Twin - 05.22-0621
    Cancer - 06.22-07.22
    Lion - 07.22-08.22
    Virgo - 08.23-09.23
    Libra - 09.24-10.23
    Scorpion -10.24-11.22
    Sagittarius - 11.23-12.22
    Capricorn - 12.23-01.19
    Aquarius- 01.20-02.18
    Fish - 02.19-03.20

  2. #2
    Join Date
    Jul 2005
    Posts
    1,074

    Re: Astrological Calculations

    After the line : "Label1.Caption = Format(intTotal2)" and before the line: "Else"Write the next lines of code
    Code:
    Dim strAux as String
    strAux = Text5.Text & Text6.Text & Text7.Text & Text8.Text
    If strAux >= "0321" And strAux <= "0420" Then SDate.Caption = "Aries"
    If strAux >= "0421" And strAux <= "0521" Then SDate.Caption = "Ox"
    If strAux >= "0522" And strAux <= "0621" Then SDate.Caption = "Twin"
    '
    ' And So on each zodiac name
    '
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3
    Join Date
    Oct 2012
    Posts
    59

    Re: Astrological Calculations

    Thanks you really match You are pro on this vb6 programming. I wonder whats you learning process must be so you can programming like this. How you study vb6?

  4. #4
    Join Date
    Jan 2009
    Posts
    596

    Re: Astrological Calculations

    Quote Originally Posted by jggtz View Post
    After the line : "Label1.Caption = Format(intTotal2)" and before the line: "Else"Write the next lines of code
    Code:
    Dim strAux as String
    strAux = Text5.Text & Text6.Text & Text7.Text & Text8.Text
    If strAux >= "0321" And strAux <= "0420" Then SDate.Caption = "Aries"
    If strAux >= "0421" And strAux <= "0521" Then SDate.Caption = "Ox"
    If strAux >= "0522" And strAux <= "0621" Then SDate.Caption = "Twin"
    '
    ' And So on each zodiac name
    '
    This pattern works (assuming that the leading zeroes are always present in Text5 and Text7) for all except 'Capricorn', as the dates for that span the end of the year.
    Following the pattern would give:
    Code:
    If strAux >= "1223" And strAux <= "0119" Then SDate.Caption = "Capricorn"
    which will obviously not be satisfied for any value of strAux. In this case you will need to use Or instead:
    Code:
    If strAux >= "1223" Or strAux <= "0119" Then SDate.Caption = "Capricorn"

  5. #5
    Join Date
    Oct 2012
    Posts
    59

    Re: Astrological Calculations

    Quote Originally Posted by Peter_B View Post
    This pattern works (assuming that the leading zeroes are always present in Text5 and Text7) for all except 'Capricorn', as the dates for that span the end of the year.
    Following the pattern would give:
    Code:
    If strAux >= "1223" And strAux <= "0119" Then SDate.Caption = "Capricorn"
    which will obviously not be satisfied for any value of strAux. In this case you will need to use Or instead:
    Code:
    If strAux >= "1223" Or strAux <= "0119" Then SDate.Caption = "Capricorn"
    So basically i need just change text from AND to OR. Thanks you :-)
    I just tried to did this what you suggest, it not going to work, it make calculation discrepancies
    Last edited by Halosar7; October 8th, 2012 at 10:37 AM.

  6. #6
    Join Date
    Jul 2005
    Posts
    1,074

    Re: [RESOLVED] Astrological Calculations

    I'm glad to help you
    You are begining to learn so your threads are elemental level as mine hehehe

    I'm in the programming languages and systems development world since 1977 and still learning
    I participate in some forums to practice my english skills
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  7. #7
    Join Date
    Jul 2005
    Posts
    1,074

    Re: [RESOLVED] Astrological Calculations

    Peter _B --> Thanks for the correction!

    Halosar7 ---> The correction apply only for Capricorn, the other remain the same
    Last edited by jggtz; October 8th, 2012 at 10:50 AM.
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  8. #8
    Join Date
    Oct 2012
    Posts
    59

    Re: [RESOLVED] Astrological Calculations

    Code:
    If strAux >= "1123" And strAux <= "1222" Then SDate.Caption = "Šaulys"
    If strAux >= "1223" Or strAux <= "0119" Then SDate.Caption = "Ožiaragis"
    If strAux >= "0120" And strAux <= "0218" Then SDate.Caption = "Vandenis"
    If strAux >= "0219" And strAux <= "0320" Then SDate.Caption = "Žuvys"
    But this correction did affect progams funcionality? Because Aquarius and fish remains same and that "or" intervened in the middle.

  9. #9
    Join Date
    Jul 2005
    Posts
    1,074

    Re: [RESOLVED] Astrological Calculations

    Post all your procedure code
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  10. #10
    Join Date
    Oct 2012
    Posts
    59

    Re: [RESOLVED] Astrological Calculations

    Quote Originally Posted by jggtz View Post
    Post all your procedure code
    Code:
    If strAux >= "0321" And strAux <= "0420" Then SDate.Caption = "Avinas"
    If strAux >= "0421" And strAux <= "0521" Then SDate.Caption = "Jautis"
    If strAux >= "0522" And strAux <= "0621" Then SDate.Caption = "Dvynys"
    If strAux >= "0622" And strAux <= "0722" Then SDate.Caption = "Vėžys"
    If strAux >= "0722" And strAux <= "0822" Then SDate.Caption = "Liūtas"
    If strAux >= "0823" And strAux <= "0923" Then SDate.Caption = "Mergelė"
    If strAux >= "0924" And strAux <= "1023" Then SDate.Caption = "Svarstyklės"
    If strAux >= "1024" And strAux <= "1122" Then SDate.Caption = "Skorpionas"
    If strAux >= "1123" And strAux <= "1222" Then SDate.Caption = "Šaulys"
    If strAux >= "1223" Or strAux <= "0119" Then SDate.Caption = "Ožiaragis"
    If strAux >= "0120" And strAux <= "0218" Then SDate.Caption = "Vandenis"
    If strAux >= "0219" And strAux <= "0320" Then SDate.Caption = "Žuvys"

  11. #11
    Join Date
    Jan 2009
    Posts
    596

    Re: [RESOLVED] Astrological Calculations

    Quote Originally Posted by Halosar7 View Post
    Code:
    If strAux >= "0321" And strAux <= "0420" Then SDate.Caption = "Avinas"
    If strAux >= "0421" And strAux <= "0521" Then SDate.Caption = "Jautis"
    If strAux >= "0522" And strAux <= "0621" Then SDate.Caption = "Dvynys"
    If strAux >= "0622" And strAux <= "0722" Then SDate.Caption = "Vėžys"
    If strAux >= "0722" And strAux <= "0822" Then SDate.Caption = "Liūtas"
    If strAux >= "0823" And strAux <= "0923" Then SDate.Caption = "Mergelė"
    If strAux >= "0924" And strAux <= "1023" Then SDate.Caption = "Svarstyklės"
    If strAux >= "1024" And strAux <= "1122" Then SDate.Caption = "Skorpionas"
    If strAux >= "1123" And strAux <= "1222" Then SDate.Caption = "Šaulys"
    If strAux >= "1223" Or strAux <= "0119" Then SDate.Caption = "Ožiaragis"
    If strAux >= "0120" And strAux <= "0218" Then SDate.Caption = "Vandenis"
    If strAux >= "0219" And strAux <= "0320" Then SDate.Caption = "Žuvys"
    Looks OK to me. What value of strAux does it not work for?

    Edit: Are you sure that strAux has the leading zeroes correctly? I.e. is the first of january "0101" rather than "11"?

  12. #12
    Join Date
    Oct 2012
    Posts
    59

    Re: [RESOLVED] Astrological Calculations

    Program works fine for now. But i dont understand why only capricorn must be with "OR" and other remains same as "AND" ?

  13. #13
    Join Date
    Jan 2009
    Posts
    596

    Re: [RESOLVED] Astrological Calculations

    Quote Originally Posted by Halosar7 View Post
    Program works fine for now. But i dont understand why only capricorn must be with "OR" and other remains same as "AND" ?
    I explained this in my first post - it is because Capricorn spans dates from the end of one year into the start of the next. Therefore the 'start' date (23rd December) is later in the year than the 'end' date (19th January).

    For all the other signs the 'start' date is earlier in the year than the 'end' date

  14. #14
    Join Date
    Jul 2005
    Posts
    1,074

    Re: [RESOLVED] Astrological Calculations

    What's the wrong result? In which sign? in which dates' range?
    But this correction did affect progams funcionality? Because Aquarius and fish remains same and that "or" intervened in the middle
    In this case there is not important the order of the instructions
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center