Private Sub Command1_Click()
Dim i As Integer, j As Integer, lpicturewidth As Long
Dim mmessage As String, lpicpos As Long, lstartmessage As Long
With Text1
   .SelStart = Len(.Text)
   .SelText = mmessage + vbCrLf
   lstartmessage = .SelStart
   End With
   
If emotions = True Then
   'For i = 1 To Form2.Picture1.Count
     ' charcombo = Split(Form2.Picture1(i - 1).Tag, " ")
        For j = 0 To 3
            
            lpicpos = InStr(lstartmessage, Text1.Text, Form2.Picture1(j).Tag)
            
            While lpicpos > 0
                
                Text1.SelStart = lpicpos - 1
                 
                Text1.SelLength = Len(charcombo(i)) 'Clear the char combo text
                Text1.SelText = ""
                TextOut Picture1.hdc, textl.SelStart, 0, Text1.Text, 20
            Picture1.PaintPicture Form2.Picture1(i).Picture, Text1.SelStart, 0, Form2.Picture1(i).ScaleWidth, Form2.Picture1(i).ScaleHeight
                
                                         lpicpos = InStr(lpicpos, Text1.Text, Form2.Picture1(j).Tag)
                
            Wend
            
        Next j
     
      'Next i
      End If
End Sub
以上代码我运行了下 居然在form1的picture1中不显示form2.picture1(j)的图片 不知道哪儿搞错了 请高手指点迷津.

解决方案 »

  1.   

    代码如果多点,能帮你调试一下,这样调试了一下,不确定的因素在多。
    --------
    www.vicmiao.com
    努力就有美好时光!
      

  2.   

    Option ExplicitPrivate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
    Private Sub Command1_Click()
     Dim charcombo() As String, i As Integer, j As Integer, lpicturewidth As Long
    Dim mmessage As String, lstartmessage As Long
    Dim lpicpos As Long
     With Text1
       .SelStart = Len(.Text)
       .SelText = mmessage + vbCrLf
       lstartmessage = .SelStart
       End With
       lpicpos = 1
     emotions = True
    If emotions = True Then
       For i = 1 To 100
         
            For j = 0 To 3
                
                lpicpos = InStr(lpicpos, Text1.Text, Form2.Picture1(j).Tag, vbTextCompare)
                
                  'Picture1.PaintPicture Form2.Picture1(0).Picture, Text1.SelStart * 4 / 3, 0, Form2.Picture1(0).ScaleWidth, Form2.Picture1(0).ScaleHeight
                If lpicpos > 0 Then
                    
                    Text1.SelStart = lpicpos
                    Text1.SelLength = Len(Form2.Picture1(i).Tag)
                    Text1.SelText = ""
                    
                    Picture1.Print Text1.Text
                
                    Text1.SelStart = lpicpos
                    
                    
                   'Picture1.PaintPicture Form2.Picture1(i).Picture, Text1.SelStart, 0, Form2.Picture1(i).ScaleWidth, Form2.Picture1(i).ScaleHeight
                  
                    lpicpos = InStr(lpicpos + 5, Text1.Text, Form2.Picture1(j).Tag)
                    Else
                    Picture1.Print Text1.Text
              End If
                
            Next j
          
          Next i
          End If
    End Sub
    Private Sub Command2_Click()
    Picture2.Print Form2.Picture1(0).Tag
    End SubPrivate Sub Form_Load()
    Picture1.ScaleMode = vbPixelsEnd Sub
      

  3.   

    还有就是在另一个窗体中有几个picturebox组,都放了几个图片
    Private Sub Form_Load()
    For i = 0 To 3
    Picture1(i).ScaleMode = vbPixels
    Next
    End SubPrivate Sub picture1_DblClick(Index As Integer)
    emotions = TrueForm1.Text1.Text = Form1.Text1.Text + Form2.Picture1(Index).Tag
    DoEvents
    'Form2.Hide
    Form1.Show
    End Sub