Solved

Webbrowser control not updating properly

Posted on 2014-01-04
4
353 Views
Last Modified: 2014-01-05
I am trying to create a calculator with an html display.  I am using the below code to create an html string for the number and decimal point input.  The code works perfectly for creating the string (WB) but does not always update the webbrowser control properly.  
    Private Sub Buttonnum(btn As Button, e As EventArgs) Handles btn0.Click, btn1.Click, btn2.Click, btn3.Click, btn4.Click,
                                                                 btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click,
                                                                 btna.Click, btnb.Click, btnx.Click, btny.Click, btnz.Click,
                                                                 btnDecimalPoint.Click
        Dim WB As String = WB2.DocumentText

        If WB = String.Empty Then
            WB = "<p dir=""RTL"">"
        Else
            If WB.Substring(WB.Length - 4) = "</p>" Then            'checks to see if "</p>" is at the end of the string.
                WB = WB.Substring(0, WB.Length - 4)   'of the string.  If it is it removes it.
            End If
        End If

        If List.Count > 0 Then
            Select Case List(List.Count - 1)
                Case "*", "+", "-", "/"
                    If btn.Text = "." Then
                        WB += "0" & btn.Text
                    Else
                        WB += btn.Text
                    End If
                Case CChar(CStr(0)) To CChar(CStr(9))
                    WB += btn.Text
            End Select
        Else
            If btn.Text = "." Then
                WB += "0" & btn.Text
            Else
                WB += btn.Text
            End If
        End If

        WB += "</p>"

        WB2.DocumentText = WB
        Application.DoEvents()
        WB2.Refresh()
        List.Add(btn.Text)

    End Sub

Open in new window

For example if I was to enter 12.3 when I press 1 then 2 ,"12" is displayed (this is good),
then when I press the decimal button ".12" is displayed (it should be 12.) I checked the value of WB and it is "12." (as it should be).
When I press 3 nothing changes ".12" is still displayed.  I then press 3 a second time and "12.3" is displayed but the value of WB is "12.33"

I have read similar issues on the web but have found no solutions.

Any suggestions?
0
Comment
Question by:NevSoFly
  • 2
  • 2
4 Comments
 
LVL 35

Assisted Solution

by:Robert Schutt
Robert Schutt earned 500 total points
ID: 39757062
Why do you use
"<p dir=""RTL"">"

Open in new window

Wouldn't that cause your problem? 'RightToLeft' is used for languages that write from right to left (so the sentence ending dot comes to the left), not for right alignment, if that's what you need? maybe use something like:
WB = "<p style=""text-align: right;"">"

Open in new window

0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39757065
Oh, by the way, losing the first digit after '.' still happens, so that is a probably a problem in your string adding logic. I think you need to add here:
Case CChar(CStr(0)) To CChar(CStr(9)), "."

Open in new window

0
 

Author Comment

by:NevSoFly
ID: 39757525
I used "<p dir=""RTL"">" because I found it in an old html book.
0
 

Author Closing Comment

by:NevSoFly
ID: 39757531
Thanks, that did the trick.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 49
ASP/VB email question 4 46
Visual Studios 1 76
VB.NET - Refactor Class per SOLID principles 2 13
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question