| | |
Convert Case To Random In Vb6
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2009
Posts: 913
Reputation:
Solved Threads: 167
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Private Sub Form_Load() Text1.Text = "This is a test. This is only a test." End Sub Private Sub Command1_Click() Randomize Dim ForLoopCounter As Integer, TextLength As Integer, TempInt As Integer TextLength = Len(Text1.Text) For ForLoopCounter = 1 To TextLength If Mid(Text1.Text, ForLoopCounter, 1) <> " " Then TempInt = (Rnd * 1) + 1 If TempInt > 1 Then ChangeCase ForLoopCounter, True, TextLength Else ChangeCase ForLoopCounter, False, TextLength End If End If Next ForLoopCounter End Sub Private Sub ChangeCase(Position As Integer, UpperCase As Boolean, StringLength As Integer) If Position = 1 Then If UpperCase = True Then Text1.Text = UCase(Left(Text1.Text, 1)) & Mid(Text1.Text, 2) Else Text1.Text = LCase(Left(Text1.Text, 1)) & Mid(Text1.Text, 2) End If ElseIf Position = StringLength Then If UpperCase = True Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & UCase(Right(Text1.Text, 1)) Else Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & LCase(Right(Text1.Text, 1)) End If Else If UpperCase = True Then Text1.Text = Left(Text1.Text, (Position - 1)) & UCase(Mid(Text1.Text, Position, 1)) & Mid(Text1.Text, (Position + 1)) Else Text1.Text = Left(Text1.Text, (Position - 1)) & LCase(Mid(Text1.Text, Position, 1)) & Mid(Text1.Text, (Position + 1)) End If End If End Sub
![]() |
Similar Threads
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Need Help to insert data to MS Access table
- Next Thread: how my computer will be open
Views: 737 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






