Ok I have an issue with the logic of the if and else statement I am not understanding why and how the logic doesn't work. I have used the statement in other programming but this is what I am wanting to do.
I am using a button with my sqrt function. In the button I am trying to use an escape route. When I press the button it gives the square root. However when I press the button again it crashes.
So for a temporary fix and learning purpose I have done this:
binding.btnSqrt.setOnClickListener{
val df = DecimalFormat("#.####")
if(!tv_equation.text.isNullOrEmpty())
{
val number = tv_equation.text.toString().toDouble()
binding.tvResult.text = df.format(sqrt(number))
else
{
binding.tvResult.text = ""
binding.tvEquation.append("")
}
However it does not imply the if else statement. I am looking at this how the statement works in WPF and UWP.
When I press the button again after that it just doubles the answer. For example in tvResult if I have 4 then when the button is pressed again it should clear but what it does is double and adds what ever is there so it shows 44 instead of clearing the textview and edittext.
Am I using the if and else statement wrong in kotlin. Or is it just the way the button is originally coded?
Related
I'm using a read-only QTextBrowser that is used to show me diagnostic message. Even though I have attempted to move the cursor to the end as well as automatically scroll to the end I keep having really annoying issues with the text outout.
I really don't want to the bottom cut off, but I don't know what else to do with it.
The code I am using to write to the box is this:
text_cursor = main_app.all_messages.textCursor()
text_cursor.movePosition(QtGui.QTextCursor.End)
main_app.all_messages.setTextCursor(text_cursor)
main_app.all_messages.insertPlainText(message + "\n")
main_app.all_messages.reload()
# always scroll to the end
scrollBar = main_app.all_messages.verticalScrollBar()
scrollBar.setValue(scrollBar.maximum())
Anything else I can try to keep this from happening?
Working with VB.NET in Visual Studio 2015. During debugging, is there any way to view the value of a variable inside a 'With' block by hovering with the mouse?
For example, in the code below, if I hover over lSection or lSection.MomentZ or lSection.MomentY or others, VS displays information about the object and/or the value of the variable (as expected).
However, if I hover over any object starting with a period (.SectionIndex or .SectionLocation or .Mx or .M_y or .Vx), VS will NOT show any tooltip at all.
NOTE: I am aware that I can add the the variable to a Watch window. I know there are other ways to get the value of the variable, but I want to be able to just hover with the mouse because it is literally (yes, literally) 900 million times faster.
I could only find one other question similar to this one, but the answer does not explain whether or not there is ANY possible way to enable this feature (VS setting, registry hack, 3rd party add-on, i don't care how)
How to view VB.NET object properties in the debugger within a "With object" block?
With mCSIDetails
.ClearCSIResults()
' Section Index and Location
.SectionIndex = lSection.ID
.SectionLocation = Round(lSection.FracLen * mMember.Length, 3)
' Section forces and moments
.P = lSection.AxialForce
If liAxis = MemberOrientation.Strong Then
.Mx = lSection.MomentZ
.M_y = lSection.MomentY
.Vx = lSection.ShearForce_CSI_12
.Vy = lSection.ShearForceZ_CSI_12
ElseIf liAxis = MemberOrientation.Weak Then
.Mx = lSection.MomentY
.M_y = lSection.MomentZ
.Vx = lSection.ShearForceZ_CSI_12
.Vy = lSection.ShearForce_CSI_12
End If
End With
I posted the same question on the Visual Studio forum and the moderator was able to replicate the issue.
Apparently this is just the new (terrible) way the debugger works. So if you want to be able to mouse-hover and get a tooltip with the object/variable value, then don't use WITH blocks...
I have 3 search box field and 3 question marks near by each search box. If I try to click on the 2nd question mark, It always clicks the 2nd Search box instead of clicking the question mark button. [Sikuli not clicking the exact element]1 Kindly have a look into the below image i have attached. Click "1" to view the image... Pls dont come up with coordinates. I shouldn't use coordinates in my project.
Well, this may not be the fully qualified answer, which do not use Region, Co-ordinates & autoIT as you are expecting.
This is code in Sikuli which uses findAll() method.
I created a dummy window as per your screenshot as below:
Edit
public void clickButton() throws AWTException, FindFailed
{
m_sikscr=new SikuliScript();
m_screen=new Screen();
m_sikscr.switchApp("Java Swing Examples");
m_screen.wait((double)3.0);
int i=0;
Match[] array=new Match[5];
Iterator<Match> rs1 = m_screen.findAll(new Pattern("./img/Button1.png"));
while(rs1.hasNext())
{
array[i]=rs1.next();
i++;
}
m_screen.click(array[1]);
}
This clicks only the second button on screen.
Hope this much triggers the thought of making it work completely.
I have the following piece of code
_Foo = String.Concat(_Foo, " Var = '", _varValue, "' ")
_Bar = DsInvoice.viewInvoice.Select(_Foo, _Order)
If _Bar.Count > 0 Then
When I place the debug lines, the Dataset is actually returning rows, and _Bar has a count of 116. Yet when it is at the 3rd line (the if statement) _Bar is empty and the count returns 0. Without any reason I just lost my data.
Let me know if you need more information (I'm actually a PHP programmer and I had to fix a legacy bit of code :(. I lack VB experience to give more background information on this code.
_Bar has no rows because there is no value equal to the _varValue in the "Column" (a.k.a "Property") in the datatable.
*Even if the Property is numeric I doubt wrapping it with single quotes will matter. *
Tip: F8 (VB.Net) or F11 (C#) to step the code control (Yellow Line) onto the second line of code. Then hover your mouse over the viewInvoice word on the second line shown in your question, you'll see the ObjectBrowser Tooltip appear and in it will be a Magnifying Glass with a dropdown. Click it (the dropdown) and select the DataTable View to help you debug this problem.
You can change the Select(...) criteria in run/debug time and then (by dragging the yellow arrow in the line number margin up a line) see the effect of the different Select criteria to work out what is going wrong.
I'm trying to programmatically set a dgrid row as active, not just selected. I have a dojo dgrid OnDemandList which is using the Selection and Keyboard Mixins.
Using the select(row) method I can programmatically select a given row, but that row is not active. When a row is active, I can use the Up and Down arrow keys to navigate to the rows above and below it. When a row is just selected, the row is highlighted but the arrows keys do not work.
Clicking the row with the mouse will make it active and selected, but I'm trying to build my interface to be 100% usable with just the keyboard.
Ok, took me awhile but got it figured out. What I was really trying to do was add focus to a row. The code for doing that was in dgrid/Keyboard.js under the _focusOnNode method.
The actual code to change focus from row currentFocusedNode to row focusedNode is:
if(currentFocusedNode){
// Clean up previously-focused element
// Remove the class name and the tabIndex attribute
put(currentFocusedNode, "!dgrid-focus[!tabIndex]");
if(has("ie") < 8){
// Clean up after workaround below (for non-input cases)
currentFocusedNode.style.position = "";
}
}
if(has("ie") < 8){
// setting the position to relative magically makes the outline
// work properly for focusing later on with old IE.
// (can't be done a priori with CSS or screws up the entire table)
focusedNode.style.position = "relative";
}
focusedNode.tabIndex = grid.tabIndex;
focusedNode.focus();
put(focusedNode, ".dgrid-focus");
The code above is really just a code fragment, for it to work you will have to declare "dojo/has" and "put-selector/put" first as well as define the currentFocusedNode and focusedNode. But I'm leaving that as an exercise for the reader ;-)
Also note that this only changes the "focus", it will not select the focusedNode but that can easily be done using grid.select(focusedNode);