SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size
SETHA SITE INFORMATION

Find and Replace text in Multiline TextBox Control in Visual Basic 6

E-mail Print PDF

This article shows you how to Find, Find Next and Replace text (including Case Sensitive option) in multiple line TextBox Control in Visual Basic 6. After you click button Find you will see InputBox to enter text you wish to find in TextBox. Then you can click button Find Next or button Replace. The below code is the sub procedure use to Find and Find Next the text in TextBox (txtContent).

Private Sub cmdFindNext_Click()
    txtContent.SetFocus
    If chkCase.Value = 1 Then
        FindText = InStr(PostFind, LCase(txtContent), LCase(TextToFind))
    Else
        FindText = InStr(PostFind, txtContent, TextToFind)
    End If
    If FindText > 0 Then
        txtContent.SelStart = FindText - 1
        txtContent.SelLength = Len(TextToFind)
        cmdReplace.Enabled = True
        PostFind = FindText + 1
    Else
        MsgBox "No text '" & TextToFind & "' any more.", vbExclamation, "Info..."
    End If
End Sub
Download Source Code
 
1) 1st Form

 
2) Text to Find

 
3) Result
 

How to Show Picture in Image Control in Visual Basic 6?

E-mail Print PDF
This article shows you the Visual Basic 6 code on how to view picture in Image Control. Additionally, in this sample you will see how to use FileListBox Control, DirListBox Control and DriveListBox Control.
Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
    Dim StrPic As String
    StrPic = File1.Path
    If Right(StrPic, 1) <> "\" Then StrPic = StrPic & "\"
    imgPic = LoadPicture(StrPic & File1.FileName)
End Sub

Download Source Code
 

How to Create Animated Writing Text in Visual Basic 6 using Timer Control?

E-mail Print PDF

This article shows you Visual Basic 6 code to create sample running text (text written) animation using Timer Control. There are three types of direction of the running text: 1) From left to right 2) From right to left and 3) from the middle. Below is the sample in timer procedure block.

Private Sub trmText_Timer()
   If lblCaption.Caption <> StrCap Then
     If lblCaption.Alignment = 0 Then
        'run from left
        lblCaption.Caption = Left(StrCap, Len(lblCaption.Caption) + 1)
     ElseIf lblCaption.Alignment = 1 Then
        'run from right
        lblCaption.Caption = Right(StrCap, Len(lblCaption.Caption) + 1)
     ElseIf lblCaption.Alignment = 2 Then
        'run from the middle
       lblCaption.Caption = Mid(StrCap, Len(StrCap) \ 2 + Len(StrCap) Mod 2 - Num, _
                            2 * (Num + 1) - Len(StrCap) Mod 2)
       Num = Num + 1
     End If
   Else
      lblCaption.Caption = ""
      Num = 0
   End If
End Sub
This is a sample output of running text from Left to Right.

Download Source Code
 

Assignment on Simulation and Modeling on “Barber Shop”

E-mail Print PDF

This article is an assignment of year fourth students of Royal University of Phnom Penh in 2004 in the course Simulation and Modeling under the Computer Science field. It describes about building a Simulation on barbershop. Choose the single server queuing system model to build the simulation. The program generation will describe on Tourbo C++ programming language. Please download document and source code in turbo C++ programming below!


 
Download Source Code
Download Document
 

How to create text file, write text file, and read text file in VB .Net?

E-mail Print PDF

This article shows you how to write Visual Basic .Net code to create Text File, write text into Text File and read content from Text File.

When we request to write text into Text File it will check first whether Text File does exist or does not. If it does not exist it will create new Text File automatically. Otherwise it will append text into the existing text file.

Write text into Text File
Dim sw As New System.IO.StreamWriter("C:\txttest.txt", True)
sw.WriteLine(txtWrite.Text)
sw.Close()

MsgBox("Save completed!")
Me.txtWrite.Text = ""
Read content from Text File
Dim sr As New System.IO.StreamReader("C:\txttest.txt")
Dim str As String
Do
   str = sr.ReadLine()
   Me.txtRead.Text += str + vbCrLf
Loop Until sr.EndOfStream = True
sr.Close()

Download Source Code
 


Page 6 of 19