Results 1 to 3 of 3

Thread: strange, but necessary - finding CurrentX and Y of string in picturebox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    In my code below, the CurrentX and Y coordinates change at random between 1000 and 2000.

    How can I get the currentX and currentY of the string 'word'? Is it possible?

    Thanks!

    -----

    Private Sub Command1_Click()

    Randomize

    Dim word As String
    Dim xcoord As Integer
    Dim ycoord As Integer
    word = "hello"
    xcoord = Int(Rnd * 1000) + 1000
    ycoord = Int(Rnd * 1000) + 1000
    Picture1.Cls
    Picture1.CurrentX = xcoord
    Picture1.CurrentY = ycoord

    Picture1.Print "I just want to say " & word & " to you all"

    End Sub

    Private Sub Command2_Click()
    'what code goes here to make the CurrentX,currentY appear in Picture2?
    End Sub

  2. #2
    Guest
    Code:
    xPosWord = xcoord + Picture1.TextWidth("I just want to say ") 
    'Don't forget the trailing space
    yPosWord = ycoord

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Public curX As String, curY As String
    
    Private Sub Command1_Click()
        Randomize
        Dim word As String
        Dim xcoord As Integer
        Dim ycoord As Integer
        
        word = "hello"
        xcoord = Int(Rnd * 1000) + 1000
        ycoord = Int(Rnd * 1000) + 1000
        Picture1.Cls
        Picture1.CurrentX = xcoord
        Picture1.CurrentY = ycoord
        
        Picture1.Print "I just want to say " & word & " to you all"
        curX = Picture1.CurrentX
        curY = Picture1.CurrentY
    End Sub
    
    Private Sub Command2_Click()
        Picture1.CurrentX = 10
        Picture1.CurrentY = 10
        Picture1.Print curX & "   " & curY
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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