S'il faut, je la créerais moi cette fonction
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub Print(ByRef Tableau() As Array, ByVal Chaine As String, Optional ByVal CouleurChaine As Integer 7, Optional ByVal CouleurFontChaine As Integer 0, Optional ByVal PositionX As Integer = -1, Optional ByVal PositionY As Integer = -1, Optional ByVal Alinea As Integer = 0) Dim Caractère As String = "" Dim CurseurX As Integer = Console.CursorLeft Dim CurseurY As Integer = Console.CursorTop If PositionX > -1 And PositionX <= Console.LargestWindowWidth Then Console.CursorLeft = PositionX End If If PositionY > -1 And PositionX <= Console.LargestWindowHeight Then Console.CursorTop = PositionY End If For Lecture As Integer = 1 To Chaine.Length Caractère = Chaine.Substring(Lecture, 1) Tableau(CurseurX, CurseurY) = Caractère ' Ici ça coince !!! Next Console.ForegroundColor = CType(CouleurChaine, ConsoleColor) Console.BackgroundColor = CType(CouleurFontChaine, ConsoleColor) If Alinea = 1 Then Console.WriteLine(Chaine) Else Console.Write(Chaine) End If End Sub
Module Module1 Public Tableau(1000, 1000, 3) As String Function ConsoleCopy(ByVal CaractèreDépart As Integer, ByVal LigneDepart As Integer, ByVal CaractèreFin As Integer, ByVal LigneFin As Integer, ByVal PositionCollageX As Integer, ByVal PositionCollageY As Integer) As Integer Console.CursorLeft = PositionCollageX Console.CursorTop = PositionCollageY For Ligne As Integer = LigneDepart To LigneFin For Caractère As Integer = CaractèreDépart To CaractèreFin Console.ForegroundColor = CType(Tableau(Caractère, Ligne, 1), ConsoleColor) Console.BackgroundColor = CType(Tableau(Caractère, Ligne, 2), ConsoleColor) Console.Write(Tableau(Caractère, Ligne, 0)) Next Next Return 0 End Function Sub Print(ByVal Chaine As String, Optional ByVal CouleurChaine As Integer 7, Optional ByVal CouleurFontChaine As Integer 0, Optional ByVal PositionX As Integer = -1, Optional ByVal PositionY As Integer = -1, Optional ByVal Alinea As Integer = 0) Dim Caractère As String = "" Dim CurseurX As Integer = Console.CursorLeft Dim CurseurY As Integer = Console.CursorTop If PositionX > -1 And PositionX <= Console.LargestWindowWidth Then Console.CursorLeft = PositionX CurseurX = PositionX End If If PositionY > -1 And PositionX <= Console.LargestWindowHeight Then Console.CursorTop = PositionY CurseurY = PositionY End If For Lecture As Integer = 0 To Chaine.Length - 1 Caractère = Chaine.Substring(Lecture, 1) Tableau(CurseurX + Lecture, CurseurY, 0) = Caractère Tableau(CurseurX + Lecture, CurseurY, 1) = CStr(CouleurChaine) Tableau(CurseurX + Lecture, CurseurY, 2) = CStr(CouleurFontChaine) Next Console.ForegroundColor = CType(CouleurChaine, ConsoleColor) Console.BackgroundColor = CType(CouleurFontChaine, ConsoleColor) If Alinea = 1 Then Console.WriteLine(Chaine) Else Console.Write(Chaine) End If End Sub Sub Main() Print("Il", ConsoleColor.Red, ConsoleColor.Yellow) Console.ResetColor() Print(" ") Print("était", ConsoleColor.Yellow, ConsoleColor.Blue) Console.ResetColor() Print(" ") Print("une", ConsoleColor.Red, ConsoleColor.White) Console.ResetColor() Print(" ") Print("fois", ConsoleColor.Yellow, ConsoleColor.DarkGreen) Console.ResetColor() Print(" ") Console.WriteLine("") ConsoleCopy(0, 0, 18, 0, 0, 2) ConsoleCopy(0, 0, 18, 0, 0, 4) ConsoleCopy(0, 0, 18, 0, 0, 6) Console.ResetColor() Console.ReadLine() End Sub End Module
Module Module1 Public Tableau(1000, 1000, 3) As String Function ConsoleCopy(ByVal CaractèreDépart As Integer, ByVal LigneDepart As Integer, ByVal CaractèreFin As Integer, ByVal LigneFin As Integer, ByVal PositionCollageX As Integer, ByVal PositionCollageY As Integer) As Integer Console.CursorLeft = PositionCollageX Console.CursorTop = PositionCollageY For Ligne As Integer = LigneDepart To LigneFin For Caractère As Integer = CaractèreDépart To CaractèreFin Print(Tableau(Caractère, Ligne, 0), CInt(Tableau(Caractère, Ligne, 1)), CInt(Tableau(Caractère, Ligne, 2))) Next Console.CursorLeft = PositionCollageX Console.CursorTop = Console.CursorTop + 1 Next Return 0 End Function Sub Print(ByVal Chaine As String, Optional ByVal CouleurChaine As Integer 7, Optional ByVal CouleurFontChaine As Integer 0, Optional ByVal PositionX As Integer = -1, Optional ByVal PositionY As Integer = -1, Optional ByVal Alinea As Integer = 0) Dim Caractère As String = "" Dim CurseurX As Integer = Console.CursorLeft Dim CurseurY As Integer = Console.CursorTop If PositionX > -1 And PositionX <= Console.LargestWindowWidth Then Console.CursorLeft = PositionX CurseurX = PositionX End If If PositionY > -1 And PositionX <= Console.LargestWindowHeight Then Console.CursorTop = PositionY CurseurY = PositionY End If For Lecture As Integer = 0 To Chaine.Length - 1 Caractère = Chaine.Substring(Lecture, 1) Tableau(CurseurX + Lecture, CurseurY, 0) = Caractère Tableau(CurseurX + Lecture, CurseurY, 1) = CStr(CouleurChaine) Tableau(CurseurX + Lecture, CurseurY, 2) = CStr(CouleurFontChaine) Next Console.ForegroundColor = CType(CouleurChaine, ConsoleColor) Console.BackgroundColor = CType(CouleurFontChaine, ConsoleColor) If Alinea = 1 Then Console.WriteLine(Chaine) Else Console.Write(Chaine) End If End Sub Sub Main() Print("Il", ConsoleColor.Red, ConsoleColor.Yellow) Console.ResetColor() Print(" ") Print("était", ConsoleColor.Yellow, ConsoleColor.Blue) Console.ResetColor() Print(" ") Print("une", ConsoleColor.Red, ConsoleColor.White) Console.ResetColor() Print(" ") Print("fois", ConsoleColor.Yellow, ConsoleColor.DarkGreen) Console.ResetColor() Print(" ") Console.WriteLine("") ConsoleCopy(0, 0, 18, 0, 0, 2) ConsoleCopy(0, 0, 18, 0, 0, 4) ConsoleCopy(0, 0, 18, 0, 0, 6) 'ConsoleCopy(0, 0, 18, 2, 0, 4) Console.ResetColor() Console.ReadLine() End Sub End Module