Solved

Webbrowser control not updating properly

Posted on 2014-01-04
4
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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