Click here to Skip to main content
15,921,250 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All.
Say you are given a sample code of a VB.net code [to calculate MD5 Checksum]
VB
Imports System.IO
    Imports System.Text
    Imports System.Diagnostics
    Imports System.Security.Cryptography
    
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Dim stopwatch As New Stopwatch
    Dim md5 As String = ""
    stopwatch.Start()
    md5 = GetMD5Checksum("C:\windows\explorer.exe")
    stopwatch.Stop()
    MsgBox("MD5 Checksum [" + md5 + "]" & Environment.NewLine & _
    "Computed in " + stopwatch.Elapsed.ToString)
    End Sub 'Button1_Click

    Public Function GetMD5Checksum(ByVal filePath As String) As String
    Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
    Dim fs As FileStream = New FileStream(filePath, FileMode.Open, _
    FileAccess.Read, FileShare.Read, 8192)
    fs = New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
    md5.ComputeHash(fs)
    fs.Close()
    Dim hash As Byte() = md5.Hash
    Dim sb As StringBuilder =NewStringBuilder
    Dim hByte As Byte
    For Each hByte In hash
    sb.Append(String.Format _
    	 "{0:X2}", hByte))
    Next
    Return sb.ToString()
    End Function 'GetMD5Checksum


If we are given the codes and I just want to create a Windows Form Application, then how can I possibly guess how many controls are required i.e. buttons, textbox, OpenFileDialog, etc without missing an element? Is there any way to go about doing this reverse technique?

Many thanks,
Giggsey
Posted
Comments
[no name] 11-Jul-12 17:01pm    
For your example, you have a button that when clicked, calls a function and displays the result in a messgebox. So to answer your question, you need exactly one button. To answer your implied question, no there is no real easy way to "know" that you need x buttons, x textboxes, etc.
Sergey Alexandrovich Kryukov 11-Jul-12 17:08pm    
Of course, the question does not make a whole lot of sense. However, the formal answer is: "at least one", which is the main form itself.
Please see my answer.
--SA
Giggsey73 12-Jul-12 0:37am    
Thanks very much.

1 solution

The create a Forms application, you are required to have at least one control — a main form (a System.Windows.Forms.Form instance is a control, System.Windows.Forms.Control).

Everything else depends on your requirements.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900