Thanks
Eric
VB code
Partial Class _Default Inherits System.Web.UI.Page Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'create variables Dim randomGenerator As New Random Dim amps As Integer = randomGenerator.Next(25, 30) Dim volts As Integer = randomGenerator.Next(110, 120) Dim watts As Double Dim KW As Double Dim path As String = "C:\Google\" watts = amps * volts KW = watts / 1000 If My.Computer.FileSystem.FileExists(path & "file.txt") Then Dim contents As String = My.Computer.FileSystem.ReadAllText(path & "file.txt") Dim value As Double Dim file As String = "C:\Google\file.txt" 'convert value = Convert.ToDouble(contents) Dim saveKW As Double = KW + value My.Computer.FileSystem.WriteAllText(file, saveKW.ToString, False) txtLKW.Text = saveKW Else Dim file As String = "C:\Google\file.txt" Dim saveKW As Double = KW My.Computer.FileSystem.WriteAllText(file, saveKW.ToString, False) txtLKW.Text = saveKW End If txtAmps.Text = amps.ToString txtVolts.Text = volts.ToString txtWatts.Text = watts.ToString txKw.Text = KW.ToString End Sub Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click Timer1.Enabled = True End Sub Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click Timer1.Enabled = False End Sub End Class
ASP/HTML
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
#btn1
{
width: 72px;
}
</style>
</head>
<body bgcolor="#666699">
<form id="form1" runat="server">
<div style="height: 247px">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Volts "></asp:Label>
<asp:TextBox ID="txtVolts" runat="server"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Logging KW"></asp:Label>
<asp:TextBox ID="txtLKW" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Amps"></asp:Label>
<asp:TextBox ID="txtAmps" runat="server"></asp:TextBox>
<asp:Label ID="lable1" runat="server" Font-Bold="True" Text="Sim KWh"></asp:Label>
<asp:TextBox ID="txtKWh" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label4" runat="server" Font-Bold="True" Text="Watts"></asp:Label>
<asp:TextBox ID="txtWatts" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label5" runat="server" Font-Bold="True" Text="KW"></asp:Label>
<asp:TextBox ID="txKw" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnStart" runat="server" BackColor="#00CC00"
BorderStyle="Inset" Font-Bold="True" ForeColor="Black" Text="Start"
Width="80px" />
<asp:Button ID="btnStop" runat="server" BackColor="Red" BorderStyle="Inset"
Font-Bold="True" ForeColor="Black" Text="Stop" Width="80px" />
<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
<br />
<br />
</div>
</form>
</body>
</html>

New Topic/Question
Reply



MultiQuote


|