Solved

Webbrowser control not updating properly

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Merging PDFs with VB.NET 10 31
Replacing HTML tags in Textarea/Textbox 5 26
Getfiles in vb.net 28 18
Close word object 13 9
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

19 Experts available now in Live!

Get 1:1 Help Now