Jump to content

Visual Basic (Visual Basic Studio) code to run in backgroud and window always on top


Recommended Posts

Posted

Dragnog thanks for the input, while I got something sorted for the program itself but this will be usefor another program I'm thinking/planning where it can inport info from csv file (inporting serveral users all in to several teams on MS Teams).

 

I'll upload the load/save update by friday I hope, it'll be the complete project so feel free to tweek etc.

  • Thanks 1
Posted (edited)

I've added the complete project, added features;

 

Advance editing;

-increases the the form window and shows richtextbox and command buttons (Load, Save, Update)

-Load loads the AppData.ini file

-Saves edited information to AppData.ini with needed shorthand labels for the code to identify where to put information while updating the rich textbox

-Updates the rich textbox with the data from the single textboxes

-Rich textbox shows the raw data from the app.ini, this can be edited and it will update the text boxes (can't not do it in reverse with out multiple change subs)

 

Better form resizing and label location (kinda)

control bar hides when program not in use

Option to show time and duration of current period above the lesson label

 

and I think thats it compaired to previous release

 

I've also added another program I was working on (but it's missing allot of it's notes) just thought if someone wanted it as well as the lesson idicator. It's called time table indicator very simlar to the lesson idicator but shows class code and tutor initials of the class for that peroid.

 

I've not added any note (or much notes) I will do late, I had trouble with it updating but I got it to work now (looking at it now I don't think it's updated lol *update below*) but it should.

 

Feel free to tweek the programs if you like I'm not fussed, any issues please do let me know and I'll see what I can do :).

 

Update found the error;

When the ticker checks the day, for Friday it stores the variable as "varDay = "Fr" " (line 134 of From1.vb), "Fr" is wrong as it should be just "F", I've updated it at my end but to save me reuploading it I'd thought I'd put a message here.

Edited by DPenfold
Posted
Sorry to jump into the thread but just wanted to say this is pretty neat idea for a program :). I had a few suggestions though for the way you trying to read/write data to your program to makes things a little easier. What I would do if it was me is the following.

 

1.) Save the data as a CSV file. As Steve mentioned, you get a whole lot more complicated but this is probably the easiest way for now. I've attached a sample below how I would lay it out

 

Normal,7:12:00,8:55:00,9:15:00,10:30:00,10:50:00,10:30:00,12:05:00,13:20:00,13:55:00,15:10:00
Lockdown,7:00:00,8:55:00,9:15:00,10:15:00,10:30:00,11:30:00,11:45:00,12:45:00,13:30:00,14:30:00
SocialDistance,7:00:00,8:50:00,9:10:00,10:20:00,10:30:00,12:15:00,11:45:00,13:05:00,13:35:00,14:50:00
Custom,7:00:00,8:55:00,9:15:00,10:15:00,10:30:00,11:30:00,11:45:00,12:45:00,13:30:00,14:30:00

 

2.) Read from the CSV file and at the same time update the textbox with the relevant data. This saves you putting the data to a richTextBox and then using string replace function to decipher the data. I would place the code in your formLoading event

 

'Open the file for reading
       Using reader As StreamReader = New StreamReader("times.csv")
           'Read the first line in the file and save to variables
           Dim line As String = reader.ReadLine
           While Not line Is Nothing
               'Keep looping till we have read all the lines
               'Split the current line everytime there is a comma and place int on array
               Dim strArr() As String = line.Split(",")
               'Get the first value in the array
               Select Case strArr(0)
                   Case "Normal"
                       'Update textboxes with relevant times
                       frmTimes.txtBefore_School_NTime.Text = strArr(1)
                       frmTimes.txtForm_Time_NTime.Text = strArr(2)
                       frmTimes.txtLesson_1_NTime.Text = strArr(3)
                       frmTimes.txtBreak1_NTime.Text = strArr(4)
                       frmTimes.txtLesson_2_NTime.Text = strArr(5)
                       frmTimes.txtBreak2_NTime.Text = strArr(6)
                       frmTimes.txtLesson_3_NTime.Text = strArr(7)
                       frmTimes.txtLunch_NTime.Text = strArr(8)
                       frmTimes.txtLesson_4_NTime.Text = strArr(9)
                       frmTimes.txtAfterSchool_NTime.Text = strArr(10)
                   Case "Lockdown"
                       'Update textboxes with relevant times
                       frmTimes.txtBefore_School_LTime.Text = strArr(1)
                       frmTimes.txtForm_Time_LTime.Text = strArr(2)
                       frmTimes.txtLesson_1_LTime.Text = strArr(3)
                       frmTimes.txtBreak1_LTime.Text = strArr(4)
                       frmTimes.txtLesson_2_LTime.Text = strArr(5)
                       frmTimes.txtBreak2_LTime.Text = strArr(6)
                       frmTimes.txtLesson_3_LTime.Text = strArr(7)
                       frmTimes.txtLunch_LTime.Text = strArr(8)
                       frmTimes.txtLesson_4_LTime.Text = strArr(9)
                       frmTimes.txtAfterSchool_LTime.Text = strArr(10)
                   Case "SocialDistance"
                       'ETC
                   Case "Custom"
                       'ETC
               End Select
               'Move onto the next line in the file
               line = reader.ReadLine
           End While
       End Using

 

3.) Write data back to the text file once changes have been made

 

           'Save changes
           Using writer As StreamWriter = New StreamWriter("times.csv")
               'Normal Times
               writer.WriteLine("Normal," & txtBefore_School_NTime.Text & "," & txtForm_Time_NTime.Text & "," & txtLesson_1_NTime.Text & "," & txtBreak1_NTime.Text & "," & txtLesson_2_NTime.Text & "," & txtBreak2_NTime.Text & "," & txtLesson_3_NTime.Text & "," & txtLunch_NTime.Text & "," & txtLesson_4_NTime.Text & "," & txtAfterSchool_NTime.Text)
           End Using

 

Note you will need to place the following code at the top of your file to get the StreamReader/StreamWriter working

 

Imports System.IO

 

Hope this is useful :)

 

Tried using this for something else but I'm getting errors if I use strArr(1)

 

Public Class Form1    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        'Open the file for reading        Using reader As StreamReader = New StreamReader("P:\Scripts\Powershell\Adding Users to Teams (from CSV lists)\Get Users and Teams\TeamsList.csv")            'Read the first line in the file and save to variables            Dim line As String = reader.ReadLine            line.Replace("""", "")            While Not line Is Nothing                'Keep looping till we have read all the lines                'Split the current line everytime there is a comma and place int on array                Dim strArr() As String = line.Split(",")                'Dim OldLines As String = RichTextBox1.Text                Dim TeamID As String = strArr(0)                    'Dim TeamName As String = strArr(1)                    Dim TeamLine As String = TeamID & "-" '& TeamName & vbNewLine                'MsgBox(strArr(0))                'TeamLine.Replace("""", "")                ListBox1.Items.Add(TeamLine)                'RichTextBox1.Text = strArr(1) & vbNewLine                'Move onto the next line in the file                line = reader.ReadLine            End While        End Using    End SubEnd Class

 

Sorry in a rush to finish for the day so I haven't coloured it etc. :(

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...