Have you experienced playing the fruit machine lottery? I am asking this question, because you might be wondering how these random combination of fruit images is generated. These machines you see aren't controlled by human manually. They are designed to do randomization process, to generate a random permutation of a sequence (such as the numbers used in a lottery game). So, the result it generates are fair and just. Can a computer also do a randomization process? Yes, absolutely! Computers are invented to perform billions of calculations each second and do mathematical arithmetic very quickly. It is a multitasking machine that is able to do more type of task that a person cannot possibly do in a very short span of time. In this tutorial, I will show you how to create an application in your computer that can do different randomization techniques using Visual Studio 2012. The project will include simple number randomization, randomizing letters in a word, generating random codes, selecting items in a list using randomization and random selection of images. I will provide the codes directly. You can download the working sample project at the end of this tutorial. *Randomize Numbers 1 to 10
Private Sub number_timer_Tick(sender As Object, e As EventArgs) Handles number_timer.Tick Randomize() txtnumber.Text = CInt(Int((10 * Rnd()) + 0)) End Sub *Randomize an Array of Letters
Private Sub word_timer_Tick(sender As Object, e As EventArgs) Handles word_timer.Tick Try Me.Cursor = Cursors.WaitCursor 'count how many letters in the word entered Dim letter_counter As Integer letter_counter = Len(txtword.Text) 'convert text to string Dim convert_string As String = txtword.Text 'create an array of characters from the word Dim myChars() As Char = convert_string.ToCharArray 'start randomizing characters Randomize() txtwordrandom.Text = myChars(CInt(Int((letter_counter * Rnd()) + 0))) Me.Cursor = Cursors.Default Catch ex As Exception Me.Cursor = Cursors.Default MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try End Sub *Randomize More than 1 Set of Numbers to Generate a Code
Private Sub code_timer_Tick(sender As Object, e As EventArgs) Handles code_timer.Tick Dim str_code_1 As String Dim str_code_2 As String Dim str_code_3 As String Dim str_code_4 As String 'code 1 Randomize() str_code_1 = CInt(Int((10 * Rnd()) + 0)) 'code 2 Randomize() str_code_2 = CInt(Int((10 * Rnd()) + 0)) 'code 3 Randomize() str_code_3 = CInt(Int((10 * Rnd()) + 0)) 'code 4 Randomize() str_code_4 = CInt(Int((10 * Rnd()) + 0)) 'generated code txtcode.Text = str_code_1 & str_code_2 & str_code_3 & str_code_4 End Sub *Select an Item from a Listbox using Randomization
Private Sub list_timer_Tick(sender As Object, e As EventArgs) Handles list_timer.Tick Dim limit As Integer limit = lst_box_eat.Items.Count 'get total number of items to randomize Randomize() lst_box_eat.SelectedIndex = (CInt(Int((limit * Rnd()) + 0))) End Sub *Randomize Collection of Images
Private Sub pic_timer_Tick_1(sender As Object, e As EventArgs) Handles pic_timer.Tick Randomize() pic_img.BackgroundImage = img_lst.Images.Item(CInt(Int((7 * Rnd()) + 0))) End Sub I guess you have an idea in your mind right after reading this. Download the complete working project below and try to work on it. IDE: Visual Studio 2012 Project Type: Visual Basic Windows Database: No Database
The commonly used method most people know to transfer or share files over the internet, which most websites use, is through HTTP or (Hyper Text Transfer Protocol). If your are doing the same method, I am here to suggest an alternative, and that is to use a special protocol called FTP or (File Transfer Protocol). It is a protocol designed for the process of transferring files from one computer to another over the Internet without interruptions. You can use this method when you want to upload or download files from remote locations in your computer anywhere you are at any time. But be sure to have an internet connection from your server before you could do the process. In this tutorial, I will discuss how to create an FTP Server Application on VB.Net. It will include an upload and download file.You can also view your actual FTP server window in a web browser component and be able to delete or rename files. Here are the steps to make an FTP Server Application. Step 1. Download FileZilla Server Application and install it on your computer.
Step 2. Setup your FileZilla FTP Server. If you have no idea on how to do it, watch this video I found on YouTube.
Step 3. After setting up your FTP Server, create a new VB project on Visual Studio and make a form design like this.
Step 4. I will not discuss all the codes involved in this project application. I will concentrate on how to LOAD, UPLOAD and DOWNLOAD file/s only. Don't worry because I have provided a download link of the complete working project at the end of this tutorial. Now let's see the codes.
*LOAD File/s from FTP Server Private Sub btn_load_Click(sender As Object, e As EventArgs) Handles btn_load.Click Try Me.Cursor = Cursors.WaitCursor If txtserveraddress.Text = Nothing Then MessageBox.Show("Enter FTP Server address.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserveraddress.Focus() ElseIf txtserverusername.Text = Nothing Then MessageBox.Show("Enter FTP Server username", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserverusername.Focus() ElseIf txtserverpassword.Text = Nothing Then MessageBox.Show("Enter FTP Server password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserverpassword.Focus() Else 'Create an FTP web request Dim ftpwebrequest As FtpWebRequest = DirectCast(WebRequest.Create("ftp://" & txtserveraddress.Text & ":21/"), FtpWebRequest) 'Set properties With ftpwebrequest 'ftp server username and password .Credentials = New NetworkCredential(txtserverusername.Text, txtserverpassword.Text) 'set the method to download .Method = WebRequestMethods.Ftp.ListDirectory 'upload timeout to 100 seconds .Timeout = "100000" End With Dim ftpwebres As FtpWebResponse = CType(ftpwebrequest.GetResponse(), FtpWebResponse) Dim ftpstreamreader As StreamReader = New StreamReader(ftpwebres.GetResponseStream()) 'clear list of files lstfiles.Items.Clear() 'start loading files from an FTP server into list While (ftpstreamreader.Peek() > -1) lstfiles.Items.Add(ftpstreamreader.ReadLine()) End While End If Me.Cursor = Cursors.Default Catch ex As Exception Me.Cursor = Cursors.Default MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try End Sub *UPLOAD a File to FTP Server Private Sub btn_upload_Click(sender As Object, e As EventArgs) Handles btn_upload.Click Try Me.Cursor = Cursors.WaitCursor If txtserveraddress.Text = Nothing Then MessageBox.Show("Enter FTP Server address.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserveraddress.Focus() ElseIf txtserverusername.Text = Nothing Then MessageBox.Show("Enter FTP Server username", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserverusername.Focus() ElseIf txtserverpassword.Text = Nothing Then MessageBox.Show("Enter FTP Server password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserverpassword.Focus() Else 'Create an FTP web request Dim ftpwebrequest As FtpWebRequest = DirectCast(WebRequest.Create("ftp://" & txtserveraddress.Text & ":21/" & get_filesafename.ToString), FtpWebRequest) 'Set properties With ftpwebrequest .Credentials = New NetworkCredential(txtserverusername.Text, txtserverpassword.Text) 'set the method to upload .Method = WebRequestMethods.Ftp.UploadFile 'upload timeout to 100 seconds .Timeout = "100000" 'data transfer type .UseBinary = True 'size of the file to upload .ContentLength = get_filename.Length End With Dim ufile() As Byte = File.ReadAllBytes(get_filename.ToString) Dim ftpwebstreamrequest As Stream = ftpwebrequest.GetRequestStream() 'start streaming upload ftpwebstreamrequest.Write(ufile, 0, ufile.Length) 'close and dispose file and request stream after the upload ftpwebstreamrequest.Close() ftpwebstreamrequest.Dispose() 'refresh web browser list tsbRefresh.PerformClick() Me.Cursor = Cursors.Default MessageBox.Show("Upload completed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Catch ex As Exception Me.Cursor = Cursors.Default MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try End Sub
*DOWNLOAD a File from FTP Server Private Sub btn_download_Click(sender As Object, e As EventArgs) Handles btn_download.Click Try Me.Cursor = Cursors.WaitCursor Dim savefildlg As SaveFileDialog = New SaveFileDialog If txtserveraddress.Text = Nothing Then MessageBox.Show("Enter FTP Server address.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserveraddress.Focus() ElseIf txtserverusername.Text = Nothing Then MessageBox.Show("Enter FTP Server username", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserverusername.Focus() ElseIf txtserverpassword.Text = Nothing Then MessageBox.Show("Enter FTP Server password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) txtserverpassword.Focus() Else 'Create a FTP web request Dim ftpwebrequest As FtpWebRequest = DirectCast(WebRequest.Create("ftp://" & txtserveraddress.Text & ":21/" & txtdownloadfile.Text), FtpWebRequest) 'Set properties With ftpwebrequest 'ftp server username and password .Credentials = New NetworkCredential(txtserverusername.Text, txtserverpassword.Text) 'set the method to download .Method = WebRequestMethods.Ftp.DownloadFile 'upload timeout to 100 seconds .Timeout = "100000" End With Dim ftpwebres As FtpWebResponse = CType(ftpwebrequest.GetResponse(), FtpWebResponse) Dim ftpstream As Stream = ftpwebres.GetResponseStream() With savefildlg .Title = "Save File Download from FTP Server" .FileName = Path.GetFullPath(ftpwebrequest.RequestUri.LocalPath) 'set type of files .Filter = "File Formats(*.jpg;*.jpeg;*.txt;*.doc;*.docx;*.zip;*.rar)|*.jpg;*.jpeg;*.txt;*.doc;*.docx;*.zip;*.rar|Image File(*.jpg;*.jpeg)|*.jpg;*.jpeg|Text File(*.txt)|*.txt|Documents(*.dic;*.docx)|*.doc;*.docx|Compressed Files(*.zip;*.rar)|*.zip;*.rar" End With 'start streaming download If savefildlg.ShowDialog = Windows.Forms.DialogResult.OK Then Dim ftpfilestream As FileStream = File.Create(savefildlg.FileName) Dim buff(1024) As Byte Dim bytesread As Integer = 0 While True bytesread = ftpstream.Read(buff, 0, buff.Length) If (bytesread = 0) Then Exit While ftpfilestream.Write(buff, 0, bytesread) End While End If Me.Cursor = Cursors.Default MessageBox.Show("Download completed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Catch ex As Exception Me.Cursor = Cursors.Default MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try End Sub ***NOTE: In this line of code "ftp://" & txtserveraddress.Text & ":21/", the number 21 in color red is the default port number of FileZilla FTP Server. You can find that value under Edit > Settings >> General Settings. Try to make an application like this if you consider it useful. Download complete working project below. IDE: Visual Studio 2012 Project Type: Visual Basic Windows Database: No Database
There are many ways to expose your website. One best effective way is to socialize. Bloggers and website owners best traffic sources are the social media sites like Facebook, Twitter and Google +. These are the places on the internet where you could share your website posts to random people for them to see and view if they find it interesting. But is there a place where bloggers like you and I can help each other to drive more traffic to our website? My answer is, YES. I've been searching lately on the internet about this and I came across these 2 interesting websites.
This is an easy way to get traffic. What you need to do here is to share your post and wait till others will take notice of it. They will help you drive traffic by sharing your post on Twitter or Facebook. If you sign up on this site, you will earn an instant 10 points credit that will be enough to share your first content. If you want to share more of your posts, you need to earn more credits by sharing some of other members posted contents. This will be a fair trade because they will do the same to you. Click here to join viralcontentbuzz.com #2.bloggers.com
If you're looking for a place to meet bloggers, then here's where they are. You can drive traffic here by posting your blog URL address for free and for some bloggers to visit your blog site. I don't really understand how this site works, but you can see your name along with your blog address on the list just after posting. I think there's no harm in trying bloggers.com.
The final stage of software application development when it is ready for client distribution is to create an installer. An installer is a software component which can either install a new program in your computer or update an old version program installed in your hard drive. Once the installation process is finished, you can open and use the application whenever you want to. Then again, If you want to remove any installed programs in your computer, you may uninstall them. If you are using Windows, you can uninstall programs under Control Panel > Programs >> Uninstall a Program.
In this tutorial, I will provide a step by step details on how to create windows installer using Inno Setup. I found Inno Setup easy and free to use in creating an installer. I've used this to create installers for my Visual Basic projects and now I would like to share it to you. I will use a visual basic windows project as my example here to create an installer using Inno Setup. So, here are the steps to follow. Step 1. Download and Install Inno Setup 5. It's free. Click here to download Inno Setup 5.
Step 2. Open a visual basic project you want to create an installer using Inno Setup.
Step 3. Publish the project. On your project Solution Explorer window, right click over project title and click Publish.
Step 4. Open the your project Publish folder and double click Setup to install your project application.
Step 5. After installing the application, Open the Task Manager and find for the location of the running application. To open Task Manager, click Start Menu and type taskmgr in Search programs and files.
Step 6. Copy and paste on your desktop the file location folder of the running application.
Step 7. Close the running application and open Inno Setup. Step 8. On the welcome screen window of Inno Setup, select Create a new script file using the Script Wizard then click OK.
Step 9. Click Next.
Step 10. Fill in needed information and click Next. Company and website are optional.
Step 11. Click Next.
Step 12. Click Browse to add exe file of the application you want to create an installer. Find that exe file in the folder you pasted on your desktop.
Step 13. Add the remaining files in the same folder where the exe file is. Except for the exe file.
Step 14. Click Next.
Step 15. Check the following check boxes on Application Icons window. Click Next.
Step 16. You may leave Application Documentation window blank and click Next to proceed.
Step 17. Select any language you want your installer to be available. English is my preferred language. Click Next.
Step 18. On the Compiler Settings window, browse for the custom compiler output folder. This is the folder where to save the output installer of your application. You can also give a name for the output installer by typing in compiler output base file name text box. Then click Next .
Step 19. Click Next.
Step 20. Then click Finish.
Step 21. Would you like to compile the new script now? Choose Yes. Step 22. Would you like to save the script before compiling? Choose No. Step 23. Finally, your application installer will be compiled. You should see result like this.
Step 24. Close Inno Setup compiler window and look for the compiled installer of your application. If you can't follow the instructions above, you may watch the video I uploaded on YouTube.