?
Solved

McRider

Posted on 2000-03-08
11
Medium Priority
?
277 Views
Last Modified: 2010-05-02
Hi!

Your code, the one with the ole objects drag and stuff is excellent.

But if I try to type any text between the images or press enter so that the image go down to the next line it looses its index. Is there anyway to work around this so that you can do anything in the rtf box and still make the images keep their indexes?

/Geo
0
Comment
Question by:Geo24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 14

Expert Comment

by:mcrider
ID: 2598589
On the keypress event, you need to check where the richtextbox SelStart property is, then walk the chain of images I created.  If the .Start property of the chain item is > than the richtextbox SelStart property, add 1 to the .Start property of the chain item...


Does this make sense?


Cheers!®©
0
 

Author Comment

by:Geo24
ID: 2599774
Almost, but where in the code do I add this?
0
 

Author Comment

by:Geo24
ID: 2600074
Adjusted points to 620
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Geo24
ID: 2600075
Can you put the code in there? Ive tried but failed.
0
 
LVL 14

Accepted Solution

by:
mcrider earned 2480 total points
ID: 2600256
This is what your RichTextBox KeyPress Event should look like...


Cheers!



THE CODE:

    Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
        Dim iVal As Long
        Dim jVal As Long
        Dim kVal As Long
        Dim lDelItem() As Long
       
        jVal = RTobject.SelStart
        kVal = RTobject.SelLength
        If RTobject.SelLength = 0 Then
            For iVal = LBound(RTobjects) To UBound(RTobjects)
                With RTobjects(iVal)
                    If jVal > .Offset And jVal < .Offset + .Length Then
                        'INSIDE OBJECT, CANT TYPE THERE.
                        Beep
                        KeyAscii = 0
                        Exit For
                    End If
                    If .Offset >= jVal Then .Offset = .Offset + 1
                End With
            Next iVal
        Else
            ReDim lDelItem(0) As Long
            For iVal = LBound(RTobjects) To UBound(RTobjects)
                With RTobjects(iVal)
                    If .Offset >= jVal And .Offset < jVal + kVal Then
                        lDelItem(UBound(lDelItem)) = iVal
                        ReDim Preserve lDelItem(UBound(lDelItem) + 1) As Long
                    End If
                    If .Offset >= jVal Then .Offset = .Offset - kVal + 1
                End With
            Next iVal
            If UBound(lDelItem) > 0 Then
                For iVal = UBound(lDelItem) - 1 To LBound(lDelItem) Step -1
                    For jVal = lDelItem(iVal) To UBound(RTobjects) - 1
                        RTobjects(jVal) = RTobjects(jVal + 1)
                    Next jVal
                    On Error Resume Next
                    ReDim Preserve RTobjects(UBound(RTobjects) - 1) As RTobjType
                    If Not Err = 0 Then ReDim RTobjects(-1) As RTobjType
                Next iVal
            End If
        End If
    End Sub
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2600349
Thanks for the points! Glad I could help!


Cheers!
0
 

Author Comment

by:Geo24
ID: 2600351
I think Im gonna post a question worth 80 points to you aswell, since you are the only one who can help me with this stuff:)

Cheers Mate!
0
 

Author Comment

by:Geo24
ID: 2600400
Everything works fine now, but you cant press enter cause then the image under the caret looses its index, is this easy to fix? And also if you delete a picture that over another one, the one below looses its index. Is there any easy way to fix this? Or is it not possible at all?
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2600404
;-)
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2600460
To fix it so the ENTER key works properly, change the KeyPress Event to look like this...


    Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
        Dim iVal As Long
        Dim jVal As Long
        Dim kVal As Long
        Dim lDelItem() As Long
        Dim lOffset As Long
       
        On Error Resume Next
        iVal = UBound(RTobjects)
        If Not Err = 0 Then Exit Sub
        If KeyAscii = 13 Then
            lOffset = 2
        Else
            lOffset = 1
        End If
       
        jVal = RTobject.SelStart
        kVal = RTobject.SelLength
       
        If RTobject.SelLength = 0 Then
            For iVal = LBound(RTobjects) To UBound(RTobjects)
                With RTobjects(iVal)
                    If jVal > .Offset And jVal < .Offset + .Length Then
                        'INSIDE OBJECT, CANT TYPE THERE.
                        Beep
                        KeyAscii = 0
                        Exit For
                    End If
                    If .Offset >= jVal Then .Offset = .Offset + lOffset
                End With
            Next iVal
        Else
            ReDim lDelItem(0) As Long
            For iVal = LBound(RTobjects) To UBound(RTobjects)
                With RTobjects(iVal)
                    If .Offset >= jVal And .Offset < jVal + kVal Then
                        lDelItem(UBound(lDelItem)) = iVal
                        ReDim Preserve lDelItem(UBound(lDelItem) + 1) As Long
                    End If
                    If .Offset >= jVal Then .Offset = .Offset - kVal + lOffset
                End With
            Next iVal
            If UBound(lDelItem) > 0 Then
                For iVal = UBound(lDelItem) - 1 To LBound(lDelItem) Step -1
                    For jVal = lDelItem(iVal) To UBound(RTobjects) - 1
                        RTobjects(jVal) = RTobjects(jVal + 1)
                    Next jVal
                    On Error Resume Next
                    ReDim Preserve RTobjects(UBound(RTobjects) - 1) As RTobjType
                    If Not Err = 0 Then ReDim RTobjects(-1) As RTobjType
                Next iVal
            End If
        End If
    End Sub






I'll have to work on the delete...  I'll get that to you later... Possibly on that 80 point question you were talking about??? ;-)


Cheers!®©
0
 

Author Comment

by:Geo24
ID: 2600578
Yes please:)

Thanx!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question