Message Box and program key

how to add a cancel button and how to add a program key

Page 1 of 1

6 Replies - 1994 Views - Last Post: 19 May 2009 - 10:16 AM Rate Topic: -----

#1 myhaksown  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 48
  • Joined: 07-January 09

Message Box and program key

Posted 19 May 2009 - 08:19 AM

How do I add a cancel button to a message box? I really need to know this because it is kinda stupid that i have a message box saying "Are you sure you want to clear everything?" and have no cancel button. Also what code do i need to make a program key where it is made so that I give a key and it works with that specific program another one will be made with a different key. I have no code for that because i have no clue where to begin (3 day trial code so it is locked would be nice to) The other problem I have is makeing the program open new windows so if i click trial then it will run for 3 days then done and with code making it run forever without the pop up again so how do I do all that? Some help would be great (I have code for the program but not for the above things).

Public Class Form1

	Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
		RichTextBox1.Undo()
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		SaveFileDialog1.Filter = "Microsoft Office Word 97-2003 Document |*.doc | All files|*.*"
		SaveFileDialog1.ShowDialog()
		If SaveFileDialog1.FileName <> "" Then
			FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
			PrintLine(1, RichTextBox1.Text)
			FileClose(1)
		End If

	End Sub

	Private Sub CloseToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem1.Click
		End
	End Sub

	Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
		SaveFileDialog1.Filter = "Microsoft Office Word 97-2003 Document |*.doc | All files|*.*"
		SaveFileDialog1.ShowDialog()
		If SaveFileDialog1.FileName <> "" Then
			FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
			PrintLine(1, RichTextBox1.Text)
			FileClose(1)
		End If

	End Sub

	Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
		Dim alltext As String = "", lineoftext As String = ""
		OpenFileDialog1.Filter = "all files|*.*"
		OpenFileDialog1.ShowDialog()
		If OpenFileDialog1.FileName <> "" Then

		End If
		Try
			FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
			Do Until EOF(1)
				lineoftext = LineInput(1)
				alltext = alltext & lineoftext & vbCrLf
			Loop
			RichTextBox1.Text = alltext
		Catch
		Finally
			FileClose(1)
		End Try

	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim alltext As String = "", lineoftext As String = ""
		OpenFileDialog1.Filter = "all files|*.*"
		OpenFileDialog1.ShowDialog()
		If OpenFileDialog1.FileName <> "" Then

		End If
		Try
			FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
			Do Until EOF(1)
				lineoftext = LineInput(1)
				alltext = alltext & lineoftext & vbCrLf
			Loop
			RichTextBox1.Text = alltext
		Catch
		Finally
			FileClose(1)
		End Try
	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		Dim AB As New PrintDialog
		Try
			AB.ShowDialog()
			RichTextBox1.Text = AB.PrintToFile
		Catch ex As Exception
			'Again, do nothing on exception'
		End Try

	End Sub

	Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
		End
	End Sub

	Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
		Dim AB As New PrintDialog
		Try
			AB.ShowDialog()
			RichTextBox1.Text = AB.PrintToFile
		Catch ex As Exception
			'Again, do nothing on exception'
		End Try

	End Sub

	Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
		FontDialog1.ShowDialog()
		RichTextBox1.SelectionFont = New Font(FontDialog1.Font, RichTextBox1.SelectionFont.Style)
	End Sub

	Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
		FontDialog1.ShowDialog()
		RichTextBox1.SelectionFont = New Font(FontDialog1.Font, RichTextBox1.SelectionFont.Style)
	End Sub

	Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
		ColorDialog1.ShowDialog()
		RichTextBox1.SelectionBackColor = ColorDialog1.Color
	End Sub

	Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
		ColorDialog1.ShowDialog()
		RichTextBox1.SelectionBackColor = ColorDialog1.Color
	End Sub

	Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
		RichTextBox1.Redo()
	End Sub

	Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
		MessageBox.Show("Are you sure you want to clear everything?")
		RichTextBox1.Text = ""
	End Sub

	Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
		RichTextBox1.Cut()
	End Sub

	Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
		RichTextBox1.Copy()
	End Sub

	Private Sub PaistToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PaistToolStripMenuItem.Click
		RichTextBox1.Paste()
	End Sub

	Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
		RichTextBox1.SelectAll()
	End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Replies To: Message Box and program key

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2239
  • View blog
  • Posts: 9,409
  • Joined: 29-May 08

Re: Message Box and program key

Posted 19 May 2009 - 08:32 AM

Examine
	 MessageBox.Show("Are you sure you want to clear everything?")


MessageBox.Show has more attributes.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Message Box and program key

Posted 19 May 2009 - 08:36 AM

Here is a list of all the overloads for MessageBox.Show, one includes using the MessageBoxButtons Enumeration telling what buttons to include with the MessageBox.

Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2239
  • View blog
  • Posts: 9,409
  • Joined: 29-May 08

Re: Message Box and program key

Posted 19 May 2009 - 08:43 AM

Also how to tell which button was pressed.
Dim ButtonPressed As Windows.Forms.DialogResult=MessageBox.Show()


Was This Post Helpful? 0
  • +
  • -

#5 JaPitbull  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 09

Re: Message Box and program key

Posted 19 May 2009 - 08:51 AM

Well, in keeping to the rules i will point u in the right direction.
  • Message Box
    The public MsgBox function as more than one optional arguments, MsgBox Style being one of them. So to answer your question you need to do something like this
    MsgBox("Your message here", MsgBoxStyle.OkCancel)
    


  • Program Key
    Keys most times often than not are a combination of encryption algorithms and some kind of special key word or random key word, that also my include some kind of salting and hashing. So in developing keys the decision is left up to you the developer as to the length of the key and how it will be authenticated, also bear in mind there is always more than one way to do the same thing in the world of programming.

    Here is a good hint from my point of view, take a look at MD5 encryption algorithm.

Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2239
  • View blog
  • Posts: 9,409
  • Joined: 29-May 08

Re: Message Box and program key

Posted 19 May 2009 - 09:10 AM

Only 1 tiny problem with that JaPitbull
MsgBox


is vb6. Doh!
Was This Post Helpful? 0
  • +
  • -

#7 eworm  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 64
  • Joined: 17-March 09

Re: Message Box and program key

Posted 19 May 2009 - 10:16 AM

Another way you can get the return value of the message box is store it in a string.

Dim strResponse as String

strResponse = MsgBox("Are you sure you want to clear?", MsgBoxStyle.Question & MsgBoxStyle.YesNo)

	 If strResponse = vbYes Then
		  ClearData()
	 Else
		  'do nothing
	 End If


This post has been edited by eworm: 19 May 2009 - 10:18 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1