Friday, 27 March 2015

'Fetch the Data from Excel using ADODB class 

Set MyObj = createobject("adodb.connection")


MyObj.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ=C:\Status.xls;Readonly=True"

Set MyDataObj = createobject("adodb.recordset")

MyDataObj.Open "select count(*) from [All_Mobile_Link$] where Status='Fail' ",MyObj

msgbox  MyDataObj(0)

Set MyDataObj = nothing
Set MyObj = nothing 

Sunday, 22 March 2015


'Function to find the Number of time Each Char exist in the String

CoutChar("aaaabbbcccccc")

Function CoutChar(InpStr)
    For i = 1 To len(InpStr)
    Char=lcase(mid(InpStr,i,1))
    Select Case Char
     Case "a"
      A=A&"a"
     Case "b"
      B=B&"b"
     Case "c"
      C=C&"c"
     Case "d"
      D=D&"d"    
      
    End Select   
    Next
  
    msgbox "Number Of time a Exist="&" "&len(A)
    msgbox "Number Of time b Exist="&" "&len(B)
    msgbox "Number Of time c Exist="&" "&len(C)   
  
End Function

Saturday, 21 March 2015


'Remove Repetative Char in a string where String has only two type of input e.g. 01010101010100000011111101011111 
'Find the number of time Repetative Char would come 

str = "01010101010100000011111101011111"
Count=0
For i = 1 to len(str)

a=mid(str,i,1)
b=mid(str,i+1,1)

If not(a=b) Then
temp=temp&a
else
Count=Count+1
End If

Next

msgbox temp
msgbox "Number Of Deletion Happen" &"="&Count

'Print Fibonacci Sequence Before the Given Number

INum = cint(inputbox("Enter The Number"))

F1=0
F2=1
Do
temp = temp&" "&F1
F3=F1+F2
F1=F2
F2=F3

Loop While F1<INum

msgbox temp 

'Find the Prime number before the given number  

INum = cint(inputbox("Enter The Number"))
For i=2 to INum
     count = 0
     j = 1
       Do while j<=i
       if i mod j = 0 Then
       count = count +1
        End If
        j=j+1
        Loop
    If count = 2 Then
    temp = temp&" "&i
    End if

  
Next
msgbox temp 

'Arrange the Number in sequence 


a = array(23,1,89,34,234,56,765,345,32,65,3)
For i=0 to ubound(a)-1
If a(i)>a(i+1Then
    c=a(i+1)
    a(i+1)=a(i)
    a(i)=c
  
End If
  
Next
For j=0 to ubound(a)
temp =temp&" "&a(j)
  
Next
msgbox(temp)

Friday, 20 March 2015


'Verify that this string is  palindrome 

call fnStrPali("dalad")

Function fnStrPali(StrPali)
    str1 = strpali
    str2 = StrReverse(str1)
    If str1 = str2 Then
        msgbox "This is a palindrom"
        Else
        msgbox "This is not a palindrom"
    End If
End Function