Results 1 to 3 of 3

Thread: [RESOLVED] having trouble with data types

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Resolved [RESOLVED] having trouble with data types

    hey yall text13.text box shows 2.48037E-03 number ,is that a + number ,if it is it conflicts with this >>(s >= 0# And s <= 1# And t >= 0# And t <= 1#)
    it shows true but it shouldnt work because it is greater than this>>s <= 1#
    thanks


    Code:
    Public Function SegmentsIntersect(ByVal x1 As Single, ByVal y1 As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal A1 As Single, ByVal B1 As Single, ByVal A2 As Single, ByVal B2 As Single) As Boolean
    Dim dx As Single
    Dim dy As Single
    Dim da As Single
    Dim db As Single
    Dim t As Single
    Dim s As Single
        dx = x2 - x1
        dy = y2 - y1
        da = A2 - A1
        db = B2 - B1
       
        If (da * dy - db * dx) = 0 Then
        
            ' The segments are parallel.
            SegmentsIntersect = False
            
            Exit Function
        End If
        s = (dx * (B1 - y1) + dy * (x1 - A1)) / (da * dy - db * dx)
        t = (da * (y1 - B1) + db * (A1 - x1)) / (db * dx - da * dy)
        SegmentsIntersect = (s >= 0# And s <= 1# And t >= 0# And t <= 1#)
        
        Text13.Text = s '2.48037E-03
        Text14.Text = t '0.3147531
        '(s >= 0# And s <= 1# And t >= 0# And t <= 1#)
    End Function

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: having trouble with data types

    2.48037E-03 is both > 0 and < 1.
    MsgBox CDbl(2.48037E-03)

    P.S. That number format is called scientific notation
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: having trouble with data types

    so its really CDbl(0.00248037),cool.
    i was woundering about that # thing ,it seems to work without it.
    why does this return ,true or false Text15.Text =(s >= 0# And s <= 1# And t >= 0# And t <= 1#)

    thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width