Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Case Statement
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
hi.
i have a text file and i whant to see if the informantion from it is the same with the one from an excel file.And i whant to use case statment for this.
For example:
ana: red
beth :blue
i read line by line the text and i whant to verify if red is the same word for ana as it is in excel and so on.

this is whant i did so for, but i don' t know ho to use corectly "Case Statement"

Code:
"Const forReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile ("C:\test_new.txt", ForReading, True, -1)
sfile = objFile.ReadAll
Lines = Split(sfile, vbCrLf)
msgbox Lines(0)
For i=1 to UBound(Lines)
   If (Lines(i) <> " ")Then
     if(inStr(Lines(i), ":") <> 0) then
    cuvant = Split(Lines(i),": ")
       Dim Verify
        [color=#FF0000]Verify = cuvant(i)[/color]   ->i don't know if called the function correctly
        [color=#FF4500]Select Case Verify[/color]
        Case "Address"
        wait 5
    If (cuvant(0) = "rand") Then                    DataTable.ImportSheet"C:\temp\excel.xls","excel","Global"
    For  j=1 to DataTable.GetRowCount
    DataTable.SetCurrentRow i
'    Wait 0.5
    If (cuvant(1) =  DataTable.Value("Rand")) then     
Reporter.ReportEvent  micPass , "a", "Passed"                              
       else                                    Reporter.ReportEvent  micFail , "b", "Failed"
    End If
end select
    Next
    End If
'    End Select
    End if
    End If
    next
"
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi,
I have a suggestion, when you wanted to compare the data in txt file with excel, why don't you convert the txt file to excel file format and then go for comparison of two excel. Note to convert the txt file to excel you must have proper field delimiters. let me know if it helps.

Regards,
Patil
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
@adelitza

If you are asking abt case statement, below is the syntax

Code:
expression="<Your expression>"
Select Case expression
Case "XXX"
  'Perofrm your operation if the expression was xxx
Case "YYY"
  'Perofrm your operation if the expression was xxx
Case Else
   ' If no matches then else case
Case End

****
For more help refer to QTP help file.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Select case is not being executed in a Function Anupama 1 1,646 05-25-2018, 11:15 AM
Last Post: Anupama
  Using Range in Select Case Statement Studymode 0 1,549 12-14-2017, 06:18 PM
Last Post: Studymode
  Using Select Case Statement Studymode 0 11,780 12-13-2017, 05:55 AM
Last Post: Studymode
  Case changes while reading values from inbuilt datatables krishnakittu03 3 3,017 04-28-2015, 11:34 AM
Last Post: kbhargava505
  Webelement innertext is not case sensitive san4hex 7 6,288 05-13-2013, 02:59 PM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)