none
TextBox Ticker

All replies

  • "How" is not accompanied by a discussion, despite of that you want to argue about that. 

    Success
    Cor

    Friday, March 24, 2017 10:27 PM
  • Austin,

    Can you describe what you mean exactly? Can you show an image of what it looks like?

    Does it have to be a textbox? How about a label? You mean like a stock ticker marquee?

    Friday, March 24, 2017 11:01 PM
  • tommytwotrain, The reason for the textbox is because I'm using the Weather Underground API to display weather alerts in a ticker. I tried a label, but it goes into multi lined and I want all text in a single line. Is it possible to tell VB to display all text in a label as a single lined and not multilined?
    Friday, March 24, 2017 11:07 PM
  • tommytwotrain, The reason for the textbox is because I'm using the Weather Underground API to display weather alerts in a ticker. I tried a label, but it goes into multi lined and I want all text in a single line. Is it possible to tell VB to display all text in a label as a single lined and not multilined?

    I don't know I cant find a setting.

    Does the line have chr(13) returns? You can remove them from the string like this. There is vblf, vbcr, and vbcrlf depending on what it is.

            Dim msg As String = "Cloudy " & vbCrLf & " Chance of Rain"
            msg = Replace(msg, vbCrLf, "")
            Label1.Text = msg
    

    Friday, March 24, 2017 11:24 PM
  • tommytwotrain, I think I have figured it out. In the feed their is a \u000A. The program is stopping the text after this. How can I prevent that?

    Here is the feed result:

    {
      "response": {
      "version":"0.1",
      "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
      "features": {
      "alerts": 1
      }
    	}
    		,"query_zone": "069",
    	"alerts": [
    		{
    		"type": "SEW",
    		"description": "Severe Thunderstorm Watch",
    		"date": "6:43 PM CDT on March 24, 2017",
    		"date_epoch": "1490398980",
    		"expires": "10:00 PM CDT on March 24, 2017",
    		"expires_epoch": "1490410800",
    		"tz_short":"CDT",
    		"tz_long":"America/Chicago",
    		"message": "\u000ASevere Thunderstorm Watch 79 remains in effect until 1000 PM CDT\u000Afor the following locations\u000A\u000A\u000AKS \u000A. Kansas counties included are\u000A\u000AButler Chase Chautauqua \u000ACowley Dickinson Elk \u000AGreenwood Harvey Lyon \u000AMcPherson Marion Morris \u000ASaline Sedgwick Sumner \u000A\u000A\u000A",
    		"phenomena": "SV",
    		"significance": "A",
    		"ZONES": [
    		{
    		"state":"KS",
    		"ZONE":"069"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"053"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"098"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"093"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"035"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"094"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"070"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"068"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"054"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"051"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"052"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"037"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"049"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"083"
    		}
    		,
    		{
    		"state":"KS",
    		"ZONE":"092"
    		}
    		],
    		"StormBased": {
    		}
    		}
    		,
    		{
    		"type": "SPE",
    		"description": "Special Statement",
    		"date": "6:42 PM CDT on March 24, 2017",
    		"date_epoch": "1490398920",
    		"expires": "7:30 PM CDT on March 24, 2017",
    		"expires_epoch": "1490401800",
    		"tz_short":"CDT",
    		"tz_long":"America/Chicago",
    		"message": "\u000AThe National Weather Service in Wichita has issued a\u000A\u000A* significant weather advisory for...\u000A southwestern Butler County in south central Kansas...\u000A\u000A* until 730 PM CDT\u000A\u000A* at 641 PM CDT...National Weather Service meteorologists were\u000A tracking a strong thunderstorm near Augusta...moving north at 10\u000A mph.\u000A\u000AHail up to the size of dimes will be possible with this storm.\u000A\u000A* Locations impacted include...\u000A El Dorado, Andover, Augusta, Douglass, Towanda, Benton, El Dorado\u000A Airport, Augusta Municipal Airport and Santa Fe Lake.\u000A\u000AA Severe Thunderstorm Watch remains in effect until 1000 PM CDT for\u000Asouth central Kansas.\u000A\u000ALat...Lon 3751 9690 3754 9712 3785 9710 3779 9677\u000Atime...Mot...loc 2342z 191deg 10kt 3762 9699 \u000A\u000A\u000AJakub\u000A\u000A",
    		"phenomena": "SP",
    		"significance": "S",
    		"ZONES": [
    		{
    		"state":"KS",
    		"ZONE":"069"
    		}
    		],
    		"StormBased": {
    		"vertices":[
    		{
    		"lat":"37.51",
    		"lon":"-96.90"
    		}
    		,
    		{
    		"lat":"37.54",
    		"lon":"-97.12"
    		}
    		,
    		{
    		"lat":"37.85",
    		"lon":"-97.10"
    		}
    		,
    		{
    		"lat":"37.79",
    		"lon":"-96.77"
    		}
    		],
    		"Vertex_count":4,
    		"stormInfo": {
    		"time_epoch": 1490398920,
    		"Motion_deg": 191,
    		"Motion_spd": 10,
    		"position_lat":37.62,
    		"position_lon":-96.99
    		}
    		}
    		}
    	]
    }
    PS: I am using the message section of the result in the ticker.

    Friday, March 24, 2017 11:51 PM
  • tommytwotrain, I think I have figured it out. In the feed their is a \u000A. The program is stopping the text after this. How can I prevent that?

    Here is the feed result:

    
    PS: I am using the message section of the result in the ticker.

    Well I am not sure. Maybe Cor or someone else knows?
    Saturday, March 25, 2017 12:07 AM
  •  How are you retrieving the string from the message section?  The \u000A is a line feed character by the way.

    If you say it can`t be done then i`ll try it

    Saturday, March 25, 2017 12:24 AM
  • IronRazerz, I am getting the string through XML.
    Saturday, March 25, 2017 12:57 AM
  • IronRazerz, I am getting the string through XML.

     Well,  i am not sure but,  you can try retrieving the string from the node/element and using the String.Replace method similar to what Tom showed but,  try replacing the LineFeed characters instead of the CarriageReturn characters.

     
    msg = msg.Replace(Chr(10), " ") 'Chr(10) is a Line Feed character


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, March 25, 2017 1:12 AM
    Saturday, March 25, 2017 1:12 AM
  •  PS - Please edit your thread and change it to a Question type instead of a Discussion type.

    If you say it can`t be done then i`ll try it

    Saturday, March 25, 2017 1:20 AM
  •  PS - Please edit your thread and change it to a Question type instead of a Discussion type.

    If you say it can`t be done then i`ll try it

    I changed it :-)

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Saturday, March 25, 2017 1:53 AM
    Moderator
  • IronRazerz, I am getting the string through XML.

     Well,  i am not sure but,  you can try retrieving the string from the node/element and using the String.Replace method similar to what Tom showed but,  try replacing the LineFeed characters instead of the CarriageReturn characters.

     
    msg = msg.Replace(Chr(10), " ") 'Chr(10) is a Line Feed character


    If you say it can`t be done then i`ll try it

    Yes it appears that is Unicode. Seems you can just remove that \u000A the same way.

    ie   Replace("\u000A", "")    not sure if replacing with a space or not matters ( " " or "" ).

    There could also be the \u000D  which is carriage. Or there could be both.

    So one of those combinations should work?

    PS I mean try chr(10) as Razerz showed. If that doe not work try removing the string \u000A as I just showed. Also you may need to do both chr(10) and chr(13).

    PSS you might have other chrs like <chr(10)><chr(13)>


    One more try using chrW. I am not sure but maybe replace(chrw(u000A), "")
    Saturday, March 25, 2017 12:39 PM
  • I tried both tommytwotrain's and IronRazerz's code and it gave me errors.
    Saturday, March 25, 2017 3:03 PM
  • Here is a class that I used to display conditions in a crawl using a textbox or label.  Nothing fancy going one here.  It could be modified to display alerts.

        Public Class WUGTicker
            ''' <summary>
            ''' set to true before ending app, then wait on Stopped
            ''' </summary>
            ''' <remarks></remarks>
            Public isStopped As New Threading.ManualResetEvent(False)
            ''' <summary>
            ''' set by DoCrawl when it is stopped
            ''' </summary>
            ''' <remarks></remarks>
            Public Stopped As New Threading.ManualResetEvent(False)
            Private _disp As Control
            Private _response As XElement
            ''' <summary>
            ''' crawl update speed in ms.
            ''' </summary>
            ''' <remarks></remarks>
            Public CrawlSpeed As Integer = 250
            Private _doCrawl As Threading.Thread
            Private initCapacity As Integer = 1024 * 10
            Private _dispBuf As New System.Text.StringBuilder(initCapacity)
            Private _dispBufLock As New Object
            Private _dispBufMirror As New System.Text.StringBuilder(initCapacity)
            Private _dispBufAppndCH As Integer = 0
    
            ''' <summary>
            ''' Constructor
            ''' </summary>
            ''' <param name="DisplayControl">label or textbox of fixed width. if label suggest AutoEllipsis = True </param>
            ''' <param name="InitialResponse">the initial response</param>
            ''' <remarks></remarks>
            Public Sub New(DisplayControl As Control, InitialResponse As XElement)
                Me._disp = DisplayControl
                Me.UpdateResponse(InitialResponse)
                'start thread to do crawl
                Me._doCrawl = New Threading.Thread(AddressOf DoCrawl)
                Me._doCrawl.IsBackground = True
                Me._doCrawl.Start()
            End Sub
    
            Public Sub UpdateResponse(Response As XElement)
                Me._response = New XElement(Response)
                Threading.Monitor.Enter(Me._dispBufLock)
                Me._dispBufAppndCH = 0
                Me._dispBufMirror.Length = 0 'clear
                Me._dispBufMirror.Append("  •  ")
    
                '
                '<<< text to display in crawl >>>
                Me._dispBufMirror.Append(Me._response.<current_observation>.<display_location>.<full>.Value)
                Me._dispBufMirror.Append("  ")
                Me._dispBufMirror.Append(Me._response.<current_observation>.<observation_time>.Value)
                Me._dispBufMirror.Append("  ")
                Me._dispBufMirror.Append(Me._response.<current_observation>.<weather>.Value)
                Me._dispBufMirror.Append("  ")
                Me._dispBufMirror.Append(Me._response.<current_observation>.<temperature_string>.Value)
                '<<< end text to display in crawl >>>
    
                Me._dispBuf.Append(Me._dispBufMirror)
                Threading.Monitor.Exit(Me._dispBufLock)
            End Sub
    
            Private Sub DoCrawl()
                Do
                    'scroll
                    If Threading.Monitor.TryEnter(Me._dispBufLock) Then
                        Me._dispBuf.Remove(0, 1) 'remove first character from crawl
                        Me._dispBuf.Append(Me._dispBufMirror(Me._dispBufAppndCH)) 'append character from mirror
                        'check bounds 
                        Me._dispBufAppndCH += 1
                        If Me._dispBufAppndCH >= Me._dispBufMirror.Length Then 'reset?
                            Me._dispBufAppndCH = 0 'yes
                        End If
                        'do update
                        Dim ds As String = Me._dispBuf.ToString
                        Me._disp.BeginInvoke(Sub()
                                                 Me._disp.Text = ds
                                             End Sub)
                        Threading.Monitor.Exit(Me._dispBufLock)
                    End If
                Loop While Not Me.isStopped.WaitOne(Me.CrawlSpeed)
                Me.Stopped.Set() 'set stopped
            End Sub
        End Class

    Here is some code I used to test it

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim cond As XElement
            cond = XElement.Load("http://api.wunderground.com/api/your api key here/conditions/q/MO/Jefferson_City.xml")
            myWUGTicker = New WUGTicker(TextBox1, cond)
            Button1.Enabled = False
            Button2.Enabled = True
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim cond As XElement
            cond = XElement.Load("http://api.wunderground.com/api/your api key here/conditions/q/MO/Jefferson_City.xml")
            myWUGTicker.UpdateResponse(cond)
        End Sub
    
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            If myWUGTicker IsNot Nothing Then
                myWUGTicker.isStopped.Set()
                myWUGTicker.Stopped.WaitOne()
            End If
    
        End Sub

    If nothing else it should give you some ideas.


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.


    • Edited by dbasnett Saturday, March 25, 2017 3:23 PM
    Saturday, March 25, 2017 3:21 PM
  • I have figured out what is going on. The alerts are multi lined text. How can I make it to where all text is on a single line?
    Saturday, March 25, 2017 4:01 PM