Solved

Webbrowser control not updating properly

Posted on 2014-01-04
4
350 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now