Choose A Random Name From A Txt File?
Jul 6, 2011Does anyone have a function that will choose a random name from a txt file that is separated by new lines?
View 5 RepliesDoes anyone have a function that will choose a random name from a txt file that is separated by new lines?
View 5 RepliesI need my code to be able to choose 5 random files from a folder. I was hoping I could instantiate the Scripting.FileSystemObject then grab the target folder as an object and do something like FolderObject.Files(12).Name but apparently that's not doable. What I did works, but is sloooow:
FS = CreateObject("Scripting.FileSystemObject")
Folder = FS.GetFolder("c: emp")
for y=1 to 5
[code]....
Sorry, it has been a long time since the last time I posted, but I did not have any idea of a project. Moreover, I had exams.Anyway, I am now facing a problem in programing a 'Sudoku' generator. However, I had an idea to solve it. Unfortunately, in this idea I need a code to pick a number in random other than:
View 9 RepliesEG: i have 5 quotes listed 1 to 5, and i want some code to generate a number 1 to 5 and the label1.text = "chosen number"i cant for the life of me work it out, i think it was dblrnd
View 2 RepliesI made a program to make a random name up from 2 textboxes on my program ( a firstname textbox and a lastname textbox). But the problem is that I'm just getting the names in order they were put in. I was using this code
Dim fname2 As String = fname.Lines(F)
Dim lname2 As String = lname.Lines(L)
and once it generated the name I would put
[code].....
I'm making a program that starts opens different folders on the user's PC. However, I want to be able to have a program in that folder selected. So, whenever the user opens up the folder after clicking a button on my form, I want one file in that folder to be pre-selected.
View 9 RepliesI need to allow users to download a file to their machine in my vb.net web app. I need them to browse to the download location themselves through some kind of navigation window.
View 1 RepliesI have a windows app where I want to allow users to choose files from their computers/network and save the actual file into the database. I've done this before with web apps and here's the code that i've always used (with an html fileupload control)
Code: Dim postedFile As HttpPostedFile = Me.FileUpload1.PostedFile
' Validate If Not postedFile Is Nothing AndAlso postedFile.ContentLength > 0 Then Dim desc As String If tbDescription.Text = "" Then desc = "" Else desc = tbDescription.Text End If
[code]....
This code put the actual file into my database table. I was wondering if there was anything like that for windows applications.
I am currently working on a family project which is based on "Who Wants To Be A Millionaire?" show. There is a huge diffrence between the show and my project. My project is a christmas edition and the goal is not to get money or something, since I will not add it... Erhmm... Let me get to the point. I have already designed a layout and scripted some things. I have about thirty questions but I do not want them to always spawn in the same array, if you know what I mean. I want the program to randomly choose one of those thirty questions and NEVER choose the same question in the same program run. By the way, there are four options on my project: A, B, C and D. I have got everything, I just need a code.
View 3 RepliesI am creating a program that will help in upload files to a website. One of the things that the website uses is the "Upload File" button. When you push it an "Open" dialog box opens (like OpenFileDialoge). What I want the program to do is auto fill in the direct file location for the website. So that the dialog box won't open or won't need input.
View 4 RepliesI am trying to find a way to allow my users to choose the directory to save files into, THe file name is automatically generated as it has a naming convention and i am able to pre program a location to save to but i d like to be able to allow my users to decide themselves which directory they want to save the files to and to have the ability to choose which directory to save to
[Code]...
I am trying to create an application where you can browse to a folder, press install button and it will copy some files to the directory of your choosing? I found some example code but how do i go on with my code from here? Cant figure out how to copy the files. You can see at last in the code i tried to copy files but its not really working, how do i use the function? I want the files to come from the application directory. And copy to the browsed folder.
Public Class Installer
Private Sub Installer_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
[Code]....
i created a form with a combobox that lists out Assignments ( assignment 1, assignment 2, etc...)......what i need to do is let the user choose an assignment, then the program should look for the matching text file in a folder, ex: user picks assignment 1, and the program will read from assignment1.txt and display the result in a listbox. I have everything except the coding to match what the user chooses and the text file to streamread.
View 10 RepliesI'm writing an Excel file recovery program with VB.Net that tries to be a convenient place to gather and access Microsoft's recommended methods. If your interested in my probably kludgy, error filled, and lacking enough cleanup code it's here: http:[url]..... The basic functionality seems to work although I haven't tested graph macro table recovery yet.
It occurred to me that Vista and Windows 7 users could benefit from being offered a list of previous versions of the file within my application if the Shadow Copy Service is on and there are previous copies. How do I do this?I looked at a lot of web pages but found no easy to crib code. One possibility I guess would be to use vssadmin via the shell but that is pretty cumbersome. I just want to display a dialogue box like the Previous Versions property sheet and allow users to pick one of the previous versions. I guess I could just display the previous version property sheet via the shell by programmatically invoking the context menu and the "Restore previous versions choice", however I also want to be able to offer the list for Vista Home Basic and Premium Users who don't have access to that tab even though apparently the previous versions still exist. Additionally if it possible I would like to offer XP users the same functionality although I'm pretty sure with XP only the System files are in the shadow copies.
I looked at MSDN on the Shadow Copy Service and went through all the pages, I also looked at AlphaVSS and AlphaFS and all the comments. I'm kind of guessing that I need to use AlphaVss and AlphFS and do the following?Find out the list of snapshots/restore points that exist on the computer.Mount those snapshots.Navigate in the mounted volumes to the Excel file the user wants to recover and make a list of those paths.With the list of paths handy, compare with some kind of diff program, the shadow copies of the files with the original.Pull out the youngest or oldest version (I don't think it matters) of those shadow copies that differ from the recovery target.List those versions of the files that are found to be different.This seems cumbersome and slow, but maybe is the fastest way to do things. I just need some confirmation that is the way to go now.
I am writing a program to calculate Pi to several hundred billion decimal places and this will require lots of GB of memory. I wrote a test program in VB2008 that saved the first 16 digits of Pi (without the decimal point) to both a text file and a random access file, just to be sure it was outputting the numbers properly. For reference the first 16 digits of Pi are:
View 8 RepliesYears ago when coding with VB6 and earlier, I used a file open command to create, read, and write a file that made it easy to store useful information.I believe it was binary and you wrote/read the data to a specific line in the file. When you opened the file with something like notepad, it just showed random ascii chars. When I needed a line of data, I could specify what line to load it from.
View 2 RepliesI am a total noob to VB and am only doing an A-level in computing. i'm using VB 2008 express edition am trying to make a windows form application which picks a random file from a folder and displays its contents in text boxes when a button is clicked.
View 3 RepliesI have managed to learn a little of VB 2008 but I'm still struggling. I managed to convert one VB6 program to VB .net but all the file IO in it is sequential access.I'm trying to convert a VB6 program to .net. This program uses almost entirely random file IO.In one of the books I have, I found an example which, with a minor mod worked. I tried using that code to modify my program and it does not work. In my code, the FileGet results in the obj containing null strings. Yet in the sample program using the same structure, the obj contains actual data.The file is being opened because the record count is calculated correctly [iUpper = LOF(F_Trk) / TrkLen].
I used a Type in VB6 which I converted to a Structure in VB 2008. The function in which the problem occurs is below as well as the Structure declaration and the Function it calls (PAB) which is a derivation of the PathAddBackslash API call.Is there an easier, more efficient way to achieve the same results in VB .NET?[code].....[code]......
Returns whole lines, the odd occasion a word. any thing obvious wrong?
Private _word As String()
Private _i As New Random
Private Sub btnGetNewhangManWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
[Code].....
I have some really sloppy code that creates an XML file with a random name. The random name (SessionID) is passed into the Sub, but the sub checks IF File.Exists first. If it does exist, it creates a new randoms file name based on System.Random (has to be done this way because it is also a SessionID).
View 4 RepliesIm creating a login system that allows staff to clock in using a 5 digit code. Staff members can also use the "add an employee" function to add a new employee to the Random File.The problem is, everytime i try to create a new employee and hit the save button, the new record writes over the existing records, one by one, everytime the programme is stopped and started up again.
My Question is: How can i get the new record to be saved, without deleting existing records,
Here is the save buttons click method:FileOpen(fileNumber, "C:employee.dat", OpenMode.Random, OpenAccess.Write) 'open the file with Write Access
myEmployee.name = txtNewName.Text 'adds the name
myEmployee.id = txtNewID.Text 'adds the ID
FilePut(fileNumber, myEmployee, n) 'save to the file
FileClose(fileNumber)
I've read numerous posts and threads about random number generation, but I havent' run across this.If I generate a bunch of random numbers, the results are radically different if I create a new Random generator for each number than if I use on Random generator for all the numbers. The results are much more consistent and evenly distributed if I use the same Random generator.I would have thought the opposite,because creating a new Random generator each time should reduce the number of random repetitions, if a different time slice is used to create the random number.[code]......
View 9 RepliesThe class Random is out right defective. It always produces the same random numbers in the same sequence. Things I have tried so far is every kind of seed you can think of as well as Randomize. The result is that I always get the same random numbers in exactly the same sequence.
View 4 RepliesI am practicing using the drawing commands, and have gotten a grass background and black happy face that moves around the background.It's a 10x10 grid of 50 pixels.I want (at the moment, when i press enter) it to generate a random number of trees (15 ~ 25) at random locations on the background. The program doesn't freak out about anything, and the variables seem to be right (using stop commands) but it's not drawing anything. Here is the code for the "GenerateTrees" command I have for when I press enter.
Private Sub GenerateTrees()
NumberOfTrees = Int(Rnd() * 10) + 15
For i = 0 To NumberOfTrees - 1
bmap.MakeTransparent(Color.Fuchsia)
[code].....
Ok guys, i am working on a really cool mini vb devoloper, but i want to be able to let the user change the icon of their program like in vb, is there a code were when a user clicks a button it opens up a file dialog and lets them select the icon and then sets it to the program destiniation file example : "C:/Test/Test2.exe"?
View 13 RepliesI signed-up to this website to have this question answered because it has been bugging me for like a week now..I have searched the forums on countless sites and found nothing.[code]...
View 1 RepliesI need an example of how to create and use a random access file
View 3 RepliesCreated Structure
opened file using FileOpen(1, "filename.dat", OpenMode.Random, , , bytes in structure)
used structure .ID = record number
FilePut(1, structure)
FileClose(1)
The program enters the first record but although when I enter more records it still shows only one record in the file.
I'm using My.Computer.Filesystem.WriteAllBytes to write out an executable stored in my application's resources to it's startup directory. After running the executable, I then delete it. Everything works fine; however, I'll randomly get an UnauthorizedAccessException for no reason. After getting the exception, I can manually delete the file with no problem. Here's the full code:
' Convert MP3
' First, copy out converter
Dim Path = New IO.FileInfo(SoundPath)
[code]....
What perplexes me is that I literally just wrote out the executable, and nothing else could possibly be using it. I've checked the file attributes and it's not read-only. My application is also running as an administrator.
how to pick a random file out of a folder and open it, lets say we have text files. And i want to click a button and a random .txt file opens in my programs textbox.
View 11 Replies