Imports System Imports System.IO Imports System.Net Imports System.Text Public Class Form1 Dim url As String Dim Dateiname, abfr As String Dim pic As Bitmap Dim schaltvariable As Integer Dim len As Integer Dim abfrx, z1, z2, z3, z4, z5, z6 Dim lastCompleteDay, timestamp_d As Integer Dim readyState As Integer = 0 Dim array(96, 5) As Integer Dim Bild As Bitmap Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load timestamp_d = Date.Today.DayOfYear + 365 * (Today.Year - 2014) + (Today.Year - 2013) / 4 Label5.Text = timestamp_d.ToString Label6.Text = Strings.Left(Today.Date.ToString, 10) Label12.Text = Today.DayOfWeek.ToString Label9.Text = (timestamp_d - 6).ToString Dim SecondDate As Date = Today Dim IntervalType As DateInterval = DateInterval.Day Dim d As Date d = DateAdd(IntervalType, -6, SecondDate) Label10.Text = d.DayOfWeek.ToString Label11.Text = Strings.Left(d.Date.ToString, 10) ' = Day("23.02.2004") PictureBox2.Load("c:\netIO_Daten\ledoff.gif") PictureBox3.Load("c:\netIO_Daten\ledoff.gif") PictureBox1.Load("c:\netIO_Daten\leer.bmp") PictureBox1.Height = 120 PictureBox1.Width = 700 '240 Bild = PictureBox1.Image Dim abfr = Bild.Height abfr = Bild.Width 'Hilfslinien For i = 1 To 700 Step 2 Bild.SetPixel(i, 30, Color.Plum) Bild.SetPixel(i, 60, Color.Plum) Bild.SetPixel(i, 90, Color.DarkKhaki) Next Dim RandU = PictureBox1.Height For i = 11 To 10 + 96 * 7 Step 24 Bild.SetPixel(i, RandU - 6, Color.Plum) Bild.SetPixel(i, RandU - 5, Color.Plum) Next For i = 11 To 10 + 96 * 7 Step 4 Bild.SetPixel(i, RandU - 4, Color.Plum) Bild.SetPixel(i, RandU - 3, Color.Plum) Bild.SetPixel(i, RandU - 2, Color.DarkKhaki) Next For i = 0 To RandU Step 2 For j = 0 To 7 Bild.SetPixel(11 + j * 96, i, Color.Plum) Next Next FileOpen(1, "c:\netIO_Daten\lastCompleteDay.txt", OpenMode.Input) Input(1, lastCompleteDay) FileClose(1) Do While (timestamp_d - lastCompleteDay) > 1 lastCompleteDay = lastCompleteDay + 1 Dateiname = sub_Dateiname(lastCompleteDay) sub_download(Dateiname) Loop FileOpen(1, "c:\netIO_Daten\lastCompleteDay.txt", OpenMode.Output) Write(1, timestamp_d - 1) FileClose(1) Dateiname = sub_Dateiname(timestamp_d) sub_download(Dateiname) sub_7Tage() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End Sub Sub sub_7Tage() 'Dim Dateinamex For i = 0 To 6 Dateiname = sub_Dateiname(timestamp_d - (6 - i)) graph(Dateiname, i * 96, 0) Next 'Dateiname = sub_Dateiname(timestamp_d) 'graph(Dateiname, 6 * 96, 1) Refresh() End Sub 'Sub graph(ByVal dayin2014 As Integer, ByVal startx As Integer) Sub graph(ByVal Datei As String, ByVal startx As Integer, ByVal web As Integer) 'len = Strings.Len(dayin2014.ToString) Dim myString As String = "" 'Dim Datei = Mid("D0000", 1, 5 - len) & dayin2014 & ".TXT" ' Try If web = 1 Then 'Dim request As HttpWebRequest = ' DirectCast(WebRequest.Create("http://leluno.selfhost.eu/" & Datei), HttpWebRequest) 'in dieser Zeile deine URL angeben 'Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse) 'Dim reader As StreamReader = New StreamReader(response.GetResponseStream()) 'abfr = reader.ReadToEnd() 'das hier ist dein String 'If Not response Is Nothing Then response.Close() Else Dim reader As New IO.StreamReader("c:\netIO_Daten\" & Datei, System.Text.Encoding.GetEncoding("windows-1252")) abfr = reader.ReadToEnd reader.Close() End If len = Strings.Len(abfr) / 21 Dim test, timestamp As Integer z1 = 16 abfrx = abfr.Substring(z1, 1) test = Asc(abfr.Substring(z1, 1)) Dim i As Integer = 0 For i = 0 To len - 1 timestamp = Asc(abfr.Substring(i * 21 + 0, 1)) 'timestamp array(timestamp, 0) = timestamp array(timestamp, 2) = Asc(abfr.Substring(i * 21 + 2, 1)) array(timestamp, 4) = Asc(abfr.Substring(i * 21 + 4, 1)) Bild.SetPixel(timestamp + startx + 10, (300 - array(timestamp, 2)) / 10 * 3, Color.Black) Bild.SetPixel(timestamp + startx + 10, (300 - array(timestamp, 4)) / 10 * 3, Color.LimeGreen) abfrx = array(timestamp, 2) / 10 z1 = array(timestamp, 4) / 10 Next ' Catch ' catch or ignore errors here ' End Try Label8.Text = abfrx.ToString & "°" Label7.Text = z1.ToString & "°" End Sub Sub sub_download(ByVal Datei As String) ' Schema: downloader.DownloadFile(Quelle als String, Ziel als String) Dim downloader As New System.Net.WebClient downloader.DownloadFile("http://leluno.selfhost.eu/" & Datei, "c:\netIO_Daten\" & Datei) End Sub Function sub_Dateiname(ByVal dayin2014 As Integer) len = Strings.Len(dayin2014.ToString) Dim Datei = Mid("D0000", 1, 5 - len) & dayin2014 & ".TXT" Return Datei End Function Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End Sub Function sub_xcmd(ByVal schaltvar As Integer) Dim Datei = "XCMD.txt" & schaltvar.ToString & "123456789ABCDEFGHIJ" 'Index'ok? testenxxx Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://leluno.selfhost.eu/" & Datei), HttpWebRequest) 'in dieser Zeile deine URL angeben Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse) Dim reader As StreamReader = New StreamReader(response.GetResponseStream()) abfr = reader.ReadToEnd() 'das hier ist dein String If Not response Is Nothing Then response.Close() 'MsgBox(Datei) Return schaltvar End Function Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged Dim c As Integer 'and xor or not Dim b As Image If CheckBox2.Checked = True Then schaltvariable = schaltvariable Or 1 b = Image.FromFile("C:\netIO_Daten\ledon.gif", 1) PictureBox2.Image = b Else schaltvariable = (schaltvariable And Not 1) b = Image.FromFile("C:\netIO_Daten\ledoff.gif", 1) PictureBox2.Image = b End If Call sub_xcmd(schaltvariable) End Sub Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged Dim c As Integer 'and xor or not Dim b As Image If CheckBox3.Checked = True Then schaltvariable = schaltvariable Or 2 b = Image.FromFile("C:\netIO_Daten\ledon.gif", 1) PictureBox3.Image = b Else schaltvariable = (schaltvariable And Not 2) b = Image.FromFile("C:\netIO_Daten\ledoff.gif", 1) PictureBox3.Image = b End If Call sub_xcmd(schaltvariable) End Sub End Class