Buongiorno a tutti!!!
Nel titolo ho già spiegato tutto. Ho cercato nel forum e ho trovato queste righr di codice
codice:
Dim stringa As String
If Len(stringa) > 4 Then
stringa1 = Mid(stringa, 1, 4)
stringa2 = Mid(stringa, 5, Len(stringa) - 4)
End If
stringa = stringa1 & Chr(13) & stringa2
Il mio problema sorge quando devo inserire queste righe nel mio cosice, che prontamente posto
codice:
' Print rotated text.
Private Sub cmdPrint_Click()
Dim MessAlert As Integer
' ____________________ * * * TITOLO GRANDE * * * ____________________
Const FONT_SIZE = 18
Const FONT_FACE = "Comic Sans"
Dim printer_hdc As Long
Dim log_font As LOGFONT
Dim new_font As Long
Dim old_font As Long
' Initialize the printer.
Printer.Print " "
' Save the hDC.
printer_hdc = Printer.hdc
' Create the rotated font.
With log_font
.lfEscapement = 900
.lfHeight = (FONT_SIZE * -20) / Printer.TwipsPerPixelY
' End the font name with a vbNullChar.
.lfFaceName = FONT_FACE & vbNullChar
End With
new_font = CreateFontIndirect(log_font)
' Select the font.
old_font = SelectObject(printer_hdc, new_font)
If txtTitolo.Text <> "" Then
' * * * CICLO PER SCEGLIERE LA POSIZIONE DI STAMPA * * *
If Option1 = True Then
' Draw the text.
TextOut printer_hdc, 450, 2250, txtTitolo.Text, Len(txtTitolo.Text)
Else
If Option2 = True Then
TextOut printer_hdc, 1300, 2250, txtTitolo.Text, Len(txtTitolo.Text)
Else
If Option3 = True Then
TextOut printer_hdc, 2200, 2250, txtTitolo.Text, Len(txtTitolo.Text)
End If
End If
End If
' Restore the original font.
SelectObject printer_hdc, old_font
DeleteObject new_font
' ____________________ * * * TITOLO PICCOLO * * * ____________________
Const FONT_SIZE_PIC = 10
Const FONT_FACE_PIC = "Comic Sans"
Dim printer_hdc_pic As Long
Dim log_font_pic As LOGFONT
Dim new_font_pic As Long
Dim old_font_pic As Long
' Create the rotated font.
With log_font_pic
.lfEscapement = 0
.lfHeight = (FONT_SIZE_PIC * -20) / Printer.TwipsPerPixelY
' End the font name with a vbNullChar.
.lfFaceName = FONT_FACE_PIC & vbNullChar
End With
new_font_pic = CreateFontIndirect(log_font_pic)
' Select the font.
old_font_pic = SelectObject(printer_hdc, new_font_pic)
' * * * CICLO PER SCEGLIERE LA POSIZIONE DI STAMPA * * *
If Option4 = True Then
' Draw the text.
TextOut printer_hdc, 100, 2570, txtTitolo.Text, Len(txtTitolo.Text)
Else
If Option5 = True Then
TextOut printer_hdc, 100, 2700, txtTitolo.Text, Len(txtTitolo.Text)
End If
End If
' Restore the original font.
SelectObject printer_hdc, old_font_pic
DeleteObject new_font_pic
Printer.EndDoc
Else
MessAlert = MsgBox("Attenzione non hai inserito alcun titolo.", vbOKOnly, "Stampa titolo per M/O Disk")
End If
End Sub
P.S. Chiedo scusa se il codice è lungo.
In parole povere il codice sopra riportato serve per stampare in determinate posizioni il contenuto di una casella di testo (txtTitolo), una volta in verticale e una volta in orizzontale. Ora, però, devo dirgli che se il txtTitolo è maggiore di 23 caratteri, allora vai alla riga successiva, dove poi io darò le coordinate come per la prima riga.
Chi mi può aiutare ad inserire il codice per tagliare la stringa???
Ringrazio tutti quanti e chiedo anticipatamente scusa ai moderatori se avessi postato nuovamente un argomento già trattato.
Grazie ancora e a presto.

