?
Solved

Webbrowser control not updating properly

Posted on 2014-01-04
4
Medium Priority
?
359 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 2000 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

771 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