Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, July 28, 2011

VB-72 : Occurrence of a String

Write a VB program to accept 2 given strings from the user and count the number of times the second string appears in the first string.
Design and display a splash screen as your program loads.

Click to see a simple program of this type The number of digits in the entered Number...
============================================
This Problem is divided into 2 parts:

  1. Provide a Splash Screen
  2. Provide a form,which find the occurrence of a string from another string.


(A)Program Design : (1)

Add a form to the project and select "Splash Screen" to get the screen as given below :



(B)Attaching Code to the Object :


Private Sub Form_Load()
    lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
    lblProductName.Caption = App.Title
End Sub



(A)Program Design : (2)



(B) Property(Controls Used) :


  • 4 Labels 
  • 3 TextBoxes, ( Set the first TextBox property - Multiline-True , ScrollBars-3)
  • One Command Button Find

(C) Attaching Code to the Object :

(The below given code starting from Public fMainForm As frmMain , may be added into a module by selecting Project-->Add Module , If there happen any error in the output)
Private Sub Command1_Click()
Dim pos, p_pos, cnt As Integer
p_pos = 1
pos = 1
cnt = 1

Do
pos = InStr(p_pos, Text1, Text2, vbTextCompare)
p_pos = p_pos + pos
If pos <> 0 Then cnt = cnt + 1
Loop While pos <> 0

Text3.Text = cnt
End Sub
Public fMainForm As frmMain

Sub Main()
frmSplash.Show
frmSplash.Refresh
Set fMainForm = New frmMain
Load fMainForm
Unload frmSplash
fMainForm.Show
End Sub


D) Output :

=========================================================================
Refer Total words,Characters,sentence,length of ... and 
  1. Count Blanks,Tabs,etc in a String
  2.   Find rightmost occurrence of n-length string

      • ====================================================================
        Back to Home   &  VB
    ===========================================================

    1 comment:

    Priyada Mohanan said...

    (The below given code starting from Public fMainForm As frmMain , may be added into a module by selecting Project-->Add Module , If there happen any error in the output)