Hello I am using the following code and trying to write the results in the excel sheet column name result, but it's not writing the results in it, however, it will export the sheet but wouldn't write the result. Can you please help me with what I am missing here? All the help is much appreciated. Thanks.
DataTable.AddSheet "TestCases"
DataTable.AddSheet "TestSteps"
DataTable.ImportSheet "this is the excel sheet", "Tcases", "TestCases"
DataTable.ImportSheet "this is the excel sheet", "Tsteps", "TestSteps"
testcasecount = DataTable.GetSheet("TestCases").GetRowCount
For i = 1 To testcasecount
DataTable.GetSheet("TestCases").SetCurrentRow (i)
If DataTable.Value("Execution", "TestCases") = "Yes" Then
stestcaseid = DataTable.GetSheet("TestCases").GetParameter("TestCaseID")
teststepcount = DataTable.GetSheet("TestSteps").GetRowCount
For j = 1 To teststepcount
DataTable.GetSheet("TestSteps").SetCurrentRow (j)
sid = DataTable.GetSheet("TestSteps").GetParameter("TestCaseID")
If DataTable.GetSheet("TestSteps").GetParameter("TestCaseID") = stestcaseid Then
Select Case DataTable.Value("Keyword", "TestSteps")
Case Browser()
sresult = Browser()
End Select
DataTable.Value("Result", "TestSteps") = sresult
End If
If sresult = "Pass" Then
DataTable.Value("Result", "TestCases") = "Pass"
End If
Next
End If
Next
DataTable.ExportSheet "this is the excel sheet", "TestCases"
DataTable.ExportSheet "this is the excel sheet", "TestSteps"
Function Browser()
systemutil.Run "chrome.exe", "www.google.com"
Browser = "Pass"
End Function
Related
I'm using the following script with a software which reads a CheckBox using OMR and outputs the data to an XML file.
Is there a way I can change it to say if more than one box has been checked, the data output should be the first checked box in the list?
Hope this makes sense.
Any help would be appreciated.
Dim installer
q_a1= Metadata.Values("OMR_FRED_P2")
q_a2= Metadata.Values("OMR_JON_P2")
q_a3= Metadata.Values("OMR_MATT_P2")
q_a4= Metadata.Values("OMR_STEVE_P2")
If q_a1 = "Filled" Then
installer = "Fred"
End If
If q_a2 = "Filled" then
installer = "Jon"
End If
If q_a3 = "Filled" then
installer = "Matt"
End If
If q_a4 = "Filled" then
installer = "Steve"
End If
call Metadata.SetValues("CompleteBy",installer)
You could do something like this:
Dim a1Checked, a2Checked, a3Checked, a4Checked
Dim numberOfChecked
a1Checked = (q_a1 = "Filled")
a2Checked = (q_a2 = "Filled")
a3Checked = (q_a3 = "Filled")
a4Checked = (q_a4 = "Filled")
numberOfChecked = Abs(a1Checked + a2Checked + a3Checked + a4Checked)
If a1Checked Or numberOfChecked > 1 Then
installer = "Fred"
ElseIf a2Checked Then
installer = "Jon"
ElseIf a3Checked Then
installer = "Matt"
ElseIf a4Checked Then
installer = "Steve"
Else
' Decide what you want to do if none is checked.
End If
Call Metadata.SetValues("CompleteBy", installer)
In VBScript, the numeric value of a "boolean true" value is -1 and of the false value is 0.
The above code simply adds the values together. If two conditions are met, the total would be -2, then we use the Abs function to get the abstract value (i.e., returning 2 instead of -2). After that, you can easily check if two or more conditions are met by using numberofChecked > 1.
I'm trying to read a specific part of a text document which will allow me to allow the user into the program.
The problem i'm having with the code is that it is able to complete the first if statement but no the second - it reads the username but not the password.
Dim usernames() As String = File.ReadAllLines(Dir$("Usernames.txt"))
For RecordNumber = 0 To UBound(usernames)
If Trim(Mid(usernames(RecordNumber), 1, 15)) = TextBox1.Text Then
If Trim(Mid(usernames(RecordNumber), 15, 30)) = TextBox2.Text Then
MsgBox("Password is correct")
End If
End If
Next RecordNumber
Any help is greatly appreciated.
Thanks
I have been a longtime lurker of stackoverflow and have now decided to join. I am trying to pull a list of every Functional Location out of SAP using BAPI. When I run this code it returns with an empty table. I dont have very much experiance with BAPI and I am trying to teach myself. Can someone please help with what im missing to make this work.
Thanks,
See code bellow:
Dim sapFunc As New SAPFunctionsOCX.SAPFunctions
Dim objServer = sapFunc.Connection
objServer.Client = "101"
objServer.User = "MyUserName"
objServer.Ticket = "MyKey"
objServer.system = "PEC"
objServer.MessageServer = "MyMessagerServer"
objServer.GroupName = "PUBLIC"
If objServer.logon(0, True) <> True Then
MsgBox("Key Rejected")
Exit Sub
End If
Dim objRfcFunc As SAPFunctionsOCX.Function
objRfcFunc = sapFunc.Add("BAPI_FUNCLOC_GETLIST")
'System.Console.Write(objRfcFunc.Description)
If objRfcFunc.Call = False Then
MsgBox("Error occured - " & objRfcFunc.Exception)
Exit Sub
End If
Dim tab = objRfcFunc.Tables("FUNCLOC_LIST")
System.Console.WriteLine("Input start:")
For I = 1 To tab.RowCount
For j = 1 To tab.ColumnCount
System.Console.Write(tab.ColumnName(j) + ":")
System.Console.WriteLine(tab.Cell(I, j))
Next
Next
System.Console.WriteLine("Input end.")
I don't intend for this to be an answer, but if it helps then that's good. If it doesn't, I'll delete it.
With objRfcFunc.tables("funcloc_ra")
If .RowCount < 1 Then .Rows.Add
.cell(1, 1) = "I"
.cell(1, 2) = "EQ"
.cell(1, 3) = "Your Func Loc"
End With
Do this after setting objRfcFunc and before calling it. The call will use these parameters.
I means to Include, EQ means you want to find items equal to the value in low.
how to send QuickTest Professional (QTP) test results to an .xls file through vb script
You can modify the pair of functions below to suit your needs.
This function initializes an Excel spreadsheet.
Function initOutExcel(sTablePath)
Datatable.addSheet "Results"
Datatable.importSheet sTablePath, "Results","Results"
iParamCount = Datatable.getSheet("Results").getParameterCount
if iParamCount = 0 Then
Datatable.getSheet("Results").addParameter "S.No",""
Datatable.getSheet("Results").addParameter "Status",""
Datatable.getSheet("Results").addParameter "Functionality",""
Datatable.getSheet("Results").addParameter "Description",""
End If
Datatable.ExportSheet sTablePath,"Results"
End Function
This function appends the Result of a Test to the end of the existing results.
Function WriteResults(sTablePath,sStatus,sFunctionality,sDescription)
Datatable.addSheet "Results"
Datatable.importSheet sTablePath, "Results","Results"
iRowCount = Datatable.getSheet("Results").getRowCount
Datatable.getSheet("Results").setCurrentRow(iRowCount+1)
Datatable("S.No","Results") = iRowCount+1
Datatable("Status","Results") = sStatus
Datatable("Description","Results") = sDescription
Datatable("Functionality","Results") = sFunctionality
Datatable.ExportSheet sTablePath,"Results"
End Function
(Source)
I am very new with programming and I have come across an issue in Visual Basic that I cannot figure out. Many forums and YouTube videos later I still do not have an answer.
I am using a nested selection structure and within it is two Message boxes. I cannot figure out how to get the second dialog result to trigger the elseif statement. It just skips over it. I believe since I have one variable declared for a dialog result it is checking both of them, but in this case I don't know how to declare only the second dialog result.
Here is the code so far.
Dim dblTotal As Double = 12
Dim strResponse As DialogResult
' Dialog box asking about a coupon and $2 coupon.
If MessageBox.Show("Does customer have a coupon?", "Coupon", MessageBoxButtons.YesNo) = vbYes AndAlso
MessageBox.Show("Does customer have a $2 coupon?", "Coupon", MessageBoxButtons.YesNo) = vbNo Then
lblTotal.Text = Convert.ToString(dblTotal - 4)
' Meant to be ran if statement is false. I dont Understand
' why it is skipping over and not executing.
' Is "dlgResult" reading the first one as well? How do I correct?
ElseIf strResponse = vbYes Then
lblTotal.Text = Convert.ToString(dblTotal - 2)
Else
lblTotal.Text = Convert.ToString(dblTotal)
End If
End Sub
I understand it would be easier to to code if the first message = vbNo, but I was trying to see if this way would work.
Thank you!!
Is this how you wanted it?
Dim dialog1 As DialogResult
Dim dialog2 As DialogResult
Dim dblTotal As Double = 12
dialog1 = MessageBox.Show("Does customer have a coupon?", "Coupon", MessageBoxButtons.YesNo)
dialog2 = MessageBox.Show("Does customer have a $2 coupon?", "Coupon", MessageBoxButtons.YesNo)
If dialog1 = DialogResult.OK Then
dblTotal = dblTotal - 2
End If
If dialog2 = DialogResult.OK Then
dblTotal = dblTotal - 2
End If
lblTotal.Text = Convert.ToString(dblTotal - 2)