Populating or executing at run time

I have two things that I need to accomplish that are both related. First I have a label that I want to display the current date, in long format, at run time. I have no idea how to make anything work automatically at run time. I don't want to have to click a button or anything to display the current date, I just want it to display automatically whenever I launch the app.
Second, I have a text file with a list of names, and I want this to populate a ComboBox at run time. The .txt file is located in the Bin folder. I'm assuming there will be some similarities on how to accomplish both of these tasks but I could be mistaken. Thanks for the help.
Steve

Comments


  • To display automatically, just stick your code into the Form1.load procedure and it will display as you get into the program.

    [Code]
    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    Label1 = system.DateTime.Today
    end sub
    [/Code]

    To display the list of names:
    [Code]
    Dim f As New Scripting.FileSystemObject
    Dim t As Scripting.TextStream
    Dim ALine As String
    t = f.OpenTextFile(Environment.CurrentDirectory & "BinNames.TXT", Scripting.IOMode.ForReading, False)
    Do While Not t.AtEndOfStream
    ALine = t.ReadLine
    ComboBox1.Items.Add(ALine)
    Loop
    t.Close()
    [/Code]


    I hope that is what you wanted.

    Relman

    : I have two things that I need to accomplish that are both related. First I have a label that I want to display the current date, in long format, at run time. I have no idea how to make anything work automatically at run time. I don't want to have to click a button or anything to display the current date, I just want it to display automatically whenever I launch the app.
    : Second, I have a text file with a list of names, and I want this to populate a ComboBox at run time. The .txt file is located in the Bin folder. I'm assuming there will be some similarities on how to accomplish both of these tasks but I could be mistaken. Thanks for the help.
    : Steve
    :

  • : Thanks for the help. The Date problem is solved. I just didn't understand where to put the code to execute it at run time.
    The ComboBox problem is a bit less easy for me to follow. I'm really new to programming and am not familiar with the Scripting function (or is it a Method?). Anyway, I have heard that I should use StreamReader to solve this problem but I don't really understand what the code should look like. I wasn't able to get your example to work although I am betting it is due to user error. Thanks again.
    Steve

    : To display automatically, just stick your code into the Form1.load procedure and it will display as you get into the program.
    :
    : [Code]
    : Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    : Label1 = system.DateTime.Today
    : end sub
    : [/Code]
    :
    : To display the list of names:
    : [Code]
    : Dim f As New Scripting.FileSystemObject
    : Dim t As Scripting.TextStream
    : Dim ALine As String
    : t = f.OpenTextFile(Environment.CurrentDirectory & "BinNames.TXT", Scripting.IOMode.ForReading, False)
    : Do While Not t.AtEndOfStream
    : ALine = t.ReadLine
    : ComboBox1.Items.Add(ALine)
    : Loop
    : t.Close()
    : [/Code]
    :
    :
    : I hope that is what you wanted.
    :
    : Relman
    :
    : : I have two things that I need to accomplish that are both related. First I have a label that I want to display the current date, in long format, at run time. I have no idea how to make anything work automatically at run time. I don't want to have to click a button or anything to display the current date, I just want it to display automatically whenever I launch the app.
    : : Second, I have a text file with a list of names, and I want this to populate a ComboBox at run time. The .txt file is located in the Bin folder. I'm assuming there will be some similarities on how to accomplish both of these tasks but I could be mistaken. Thanks for the help.
    : : Steve
    : :
    :
    :

  • I used a textstream that was under the Scripting namespace, so don't worry about the Scripting part of it. The code I used (as far as I know) is an example of how to use a Stream Reader (Or in this case, a TextReader).

    Your error might have been becuase of the location I typed in - maybe try fiddling with that. If that wasn't the problem, then tell me what the error was (what did .NET Studio say when it gave you the option to break execution?) and I may be able to be of more help.

    Relman

    : : Thanks for the help. The Date problem is solved. I just didn't understand where to put the code to execute it at run time.
    : The ComboBox problem is a bit less easy for me to follow. I'm really new to programming and am not familiar with the Scripting function (or is it a Method?). Anyway, I have heard that I should use StreamReader to solve this problem but I don't really understand what the code should look like. I wasn't able to get your example to work although I am betting it is due to user error. Thanks again.
    : Steve
    :
    : : To display automatically, just stick your code into the Form1.load procedure and it will display as you get into the program.
    : :
    [Code]
    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    Label1.Text = system.DateTime.Today
    end sub
    [/Code]
    : :
    : : To display the list of names:
    : : [Code]
    : : Dim f As New Scripting.FileSystemObject
    : : Dim t As Scripting.TextStream
    : : Dim ALine As String
    : : t = f.OpenTextFile(Environment.CurrentDirectory & "BinNames.TXT", Scripting.IOMode.ForReading, False)
    : : Do While Not t.AtEndOfStream
    : : ALine = t.ReadLine
    : : ComboBox1.Items.Add(ALine)
    : : Loop
    : : t.Close()
    : : [/Code]
    : :
    : :
    : : I hope that is what you wanted.
    : :
    : : Relman
    : :
    : : : I have two things that I need to accomplish that are both related. First I have a label that I want to display the current date, in long format, at run time. I have no idea how to make anything work automatically at run time. I don't want to have to click a button or anything to display the current date, I just want it to display automatically whenever I launch the app.
    : : : Second, I have a text file with a list of names, and I want this to populate a ComboBox at run time. The .txt file is located in the Bin folder. I'm assuming there will be some similarities on how to accomplish both of these tasks but I could be mistaken. Thanks for the help.
    : : : Steve
    : : :
    : :
    : :
    :
    :

  • This worked out with a bit of tweaking. Thanks for your help.
    Steve
    : I used a textstream that was under the Scripting namespace, so don't worry about the Scripting part of it. The code I used (as far as I know) is an example of how to use a Stream Reader (Or in this case, a TextReader).
    :
    : Your error might have been becuase of the location I typed in - maybe try fiddling with that. If that wasn't the problem, then tell me what the error was (what did .NET Studio say when it gave you the option to break execution?) and I may be able to be of more help.
    :
    : Relman
    :
    : : : Thanks for the help. The Date problem is solved. I just didn't understand where to put the code to execute it at run time.
    : : The ComboBox problem is a bit less easy for me to follow. I'm really new to programming and am not familiar with the Scripting function (or is it a Method?). Anyway, I have heard that I should use StreamReader to solve this problem but I don't really understand what the code should look like. I wasn't able to get your example to work although I am betting it is due to user error. Thanks again.
    : : Steve
    : :
    : : : To display automatically, just stick your code into the Form1.load procedure and it will display as you get into the program.
    : : :
    : [Code]
    : Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    : Label1.Text = system.DateTime.Today
    : end sub
    : [/Code]
    : : :
    : : : To display the list of names:
    : : : [Code]
    : : : Dim f As New Scripting.FileSystemObject
    : : : Dim t As Scripting.TextStream
    : : : Dim ALine As String
    : : : t = f.OpenTextFile(Environment.CurrentDirectory & "BinNames.TXT", Scripting.IOMode.ForReading, False)
    : : : Do While Not t.AtEndOfStream
    : : : ALine = t.ReadLine
    : : : ComboBox1.Items.Add(ALine)
    : : : Loop
    : : : t.Close()
    : : : [/Code]
    : : :
    : : :
    : : : I hope that is what you wanted.
    : : :
    : : : Relman
    : : :
    : : : : I have two things that I need to accomplish that are both related. First I have a label that I want to display the current date, in long format, at run time. I have no idea how to make anything work automatically at run time. I don't want to have to click a button or anything to display the current date, I just want it to display automatically whenever I launch the app.
    : : : : Second, I have a text file with a list of names, and I want this to populate a ComboBox at run time. The .txt file is located in the Bin folder. I'm assuming there will be some similarities on how to accomplish both of these tasks but I could be mistaken. Thanks for the help.
    : : : : Steve
    : : : :
    : : :
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories