2019年8月29日 星期四

將字串分割,並產生字串陣列

將字串分割,並產生字串陣列
--

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' === 字串切割 ===
        Dim MyString = "09/02/04     4:00p   21.9 21.9  21.8 69     15.9            3.6 NE        2.15 6.3 "
        Dim charSeparators() As Char = {" "c}
        Dim strResult() = MyString.Trim().Split(charSeparators, StringSplitOptions.RemoveEmptyEntries)

        ' === 顯示 ===
        For i As Integer = 0 To strResult.Length - 1
            Me.TextBox1.Text += strResult(i) + Environment.NewLine
        Next
    End Sub
End Class

讀取及寫入文字檔

如何讀取和寫入至文字檔案,使用 Visual Basic 2005年或 Visual Basic.NET
--
'Read a Text FileImports System.IO
Module Module1

    Sub Main()
        Dim objStreamReader As StreamReader
        Dim strLine As String

        'Pass the file path and the file name to the StreamReader constructor.
        objStreamReader = New StreamReader("C:\Boot.ini")

        'Read the first line of text.
        strLine = objStreamReader.ReadLine

        'Continue to read until you reach the end of the file.
        Do While Not strLine Is Nothing

            'Write the line to the Console window.
            Console.WriteLine(strLine)

            'Read the next line.
            strLine = objStreamReader.ReadLine
        Loop

        'Close the file.
        objStreamReader.Close()

        Console.ReadLine()
    End Sub
End Module

'Write a Text File: Version 1
Imports System.IO
Module Module1

    Sub Main()
        Dim objStreamWriter As StreamWriter

        'Pass the file path and the file name to the StreamWriter constructor.
        objStreamWriter = New StreamWriter("C:\Text.txt")

        'Write a line of text.
        objStreamWriter.WriteLine("Hello World")

        'Write a second line of text.
        objStreamWriter.WriteLine("From the StreamWriter class")

        'Close the file.
        objStreamWriter.Close()

    End Sub
End Module

'Write a Text File: Version 2
Imports System.IO
Imports System.Text
Module Module1

    Sub Main()
        Dim objStreamWriter As StreamWriter
        Dim x As Long

        'Open the file.
        objStreamWriter = New StreamWriter("C:\Test2.txt", True, _
           Encoding.Unicode)

        'Write out the numbers 1 through 10 on the same line.
        For x = 1 To 10
            objStreamWriter.Write(x)
        Next x

        'Close the file.
        objStreamWriter.Close()
    End Sub

End Module

使用C#操作Sftp

使用C#操作Sftp
--

2019年8月28日 星期三

POS 2019 全新架構開發(1)

POS 系統 2019 全新開發

架構 : 單機+多門市+總部系統

擱了整整6年,現總算要動工開始開發了....

目標 : 一鍵安裝  + 傻瓜操作

持續開發中... 將不定時放上POS系統進度功能圖

完工後,將會釋放讓大家下載測試使用(當然是要付費的...)

---










2019年8月26日 星期一

判斷是否已開啟視窗

參考來源
---
法一 - A、
只能在 父MDI [MAIN_ligoHRsys] 下運作! 當嵌入其它組件時,無法在其下 父MDI 下運算!
        '若表單已存在 則讓他為主要顯示表單
        If l_Frm IsNot Nothing Then

            For i As Integer = 0 To MAIN_ligoHRsys.FindForm().MdiChildren.Length - 1
                If frmText.Equals(MAIN_ligoHRsys.FindForm().MdiChildren(i).Text) Then
                    MAIN_ligoHRsys.FindForm().MdiChildren(i).Tag = 4
                    MAIN_ligoHRsys.FindForm().MdiChildren(i).Activate()
                    DirectCast(MAIN_ligoHRsys.FindForm().MdiChildren(i), Object).MyDataRequery(Nothing)
                End If
            Next
        End If


法一 - B、
當嵌入在任何組件時 在其 父MDI 下運作,必使用 Me.Parent 方可執行!
        '若表單已存在 則讓他為主要顯示表單
        If l_Frm IsNot Nothing Then

            For i As Integer = 0 To Me.Parent.FindForm().MdiChildren.Length - 1
                If frmText.Equals(Me.Parent.FindForm.MdiChildren(i).Text) Then
                    Me.Parent.FindForm.MdiChildren(i).Activate()
                    Me.Parent.FindForm.MdiChildren(i).Tag = 1
                    DirectCast(Me.Parent.FindForm().MdiChildren(i), Object).MyDataRequery(Nothing)
                End If
            Next
        End If


法二、
If My.Application.OpenForms.Item("FormName") IsNot Nothing Then
     'do something here 已經打開
Else
     'do something here 還沒打開
End If

2019年8月21日 星期三

寫 XML 檔

Imports System.Xml
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim writer As New XmlTextWriter("product.xml", System.Text.Encoding.UTF8)
        writer.WriteStartDocument(True)
        writer.Formatting = Formatting.Indented
        writer.Indentation = 2
        writer.WriteStartElement("Table")
        createNode(1, "Product 1", "1000", writer)
        createNode(2, "Product 2", "2000", writer)
        createNode(3, "Product 3", "3000", writer)
        createNode(4, "Product 4", "4000", writer)
        writer.WriteEndElement()
        writer.WriteEndDocument()
        writer.Close()
    End Sub
    Private Sub createNode(ByVal pID As String, ByVal pName As String, ByVal pPrice As String, ByVal writer As XmlTextWriter)
        writer.WriteStartElement("Product")
        writer.WriteStartElement("Product_id")
        writer.WriteString(pID)
        writer.WriteEndElement()
        writer.WriteStartElement("Product_name")
        writer.WriteString(pName)
        writer.WriteEndElement()
        writer.WriteStartElement("Product_price")
        writer.WriteString(pPrice)
        writer.WriteEndElement()
        writer.WriteEndElement()
    End Sub
End Class


2019年8月15日 星期四

讀 XML 檔

Imports System.Xml
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim xmlDoc As New XmlDocument()
        xmlDoc.Load("d:\product.xml")
        Dim nodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("/Table/Product")
        Dim pID As String = "", pName As String = "", pPrice As String = ""
        For Each node As XmlNode In nodes
            pID = node.SelectSingleNode("Product_id").InnerText
            pName = node.SelectSingleNode("Product_name").InnerText
            pPrice = node.SelectSingleNode("Product_price").InnerText
            MessageBox.Show(pID & " " & pName & " " & pPrice)
        Next
    End Sub
End Class

2019年8月6日 星期二

歡迎來到 twstock 文件系統

歡迎來到 twstock 文件系統
--

python爬蟲 — 每日即時股價

python爬蟲 — 每日即時股價
---
主要參數:
https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_1101.tw|tse_1102.tw|tse_1103.tw&json=1&delay=0&_=1552123547443

--
相關參考:
證交所即時資訊解析

http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=(tse|otc)_SYMBOL.tw_YYYYMMDD&json=1&delay=0

例如 http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_3474.tw_20140801&json=1&delay=0 可以取得 2014/8/1 當日的華亞科的股價(經測試不打_20140801&仍可取得最新資料)

這次的API也可以進行串接,例如同時取得華亞科與精華的股價可以使用 | (pipe符號) 進行串接,例如
http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_3474.tw_20140804|otc_1565.tw_20140804&json=1&delay=0

取得指數的方式如下:
http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=指數代號&json=1&delay=0

給個例子,同時取得上市與上櫃指數
http://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_t00.tw|otc_o00.tw&json=1&delay=0

參數說明:
(tse|otc): 若是上市使用tse,若是上櫃則使用otc, 注意左右括號要拿掉
SYMBOL:則是4碼或6碼的股票代號
YYYYMMDD:則是當日日期

回傳的JSON欄位說明
z當盤成交價
tv當盤成交量
v累積成交量
b揭示買價(從高到低,以_分隔資料)
g揭示買量(配合b,以_分隔資料)
a揭示賣價(從低到高,以_分隔資料)
f揭示賣量(配合a,以_分隔資料)
o開盤
h最高
l最低
y昨收
u漲停價
w跌停價
tlongepoch毫秒數
d最近交易日期(YYYYMMDD)
t最近成交時刻(HH:MI:SS)
c股票代號
n公司簡稱
nf公司全名
註解
您沒有新增註解的權限。

---

臺灣證券交易所-基本市況報導網站



python 入門到分析股市

python 入門到分析股市
---
出處: iT 邦幫忙