|
i have this project which i need to finish in the next week or so. the project is a version of notepad in vb.net, so far everything is ok but when you run the programme the design does not show in the form and i dont know why. so if any one of you geniuses can help me i would be eternally grateful.
heres the code:
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Namespace notepad
_
Public Class Form1
Inherits System.Windows.Forms.Form
Private components As System.ComponentModel.IContainer
Private pageSetupDialog1 As System.Windows.Forms.PageSetupDialog
Private WithEvents menuItem_color As System.Windows.Forms.MenuItem
Private colorDialog1 As System.Windows.Forms.ColorDialog
Private fontDialog1 As System.Windows.Forms.FontDialog
Private openFileDialog1 As System.Windows.Forms.OpenFileDialog
Private printDialog1 As System.Windows.Forms.PrintDialog
Private saveFileDialog1 As System.Windows.Forms.SaveFileDialog
Private statusBar1 As System.Windows.Forms.StatusBar
Private WithEvents textBox_pad As System.Windows.Forms.TextBox
Private menuItem4 As System.Windows.Forms.MenuItem
Private WithEvents menuItem_font As System.Windows.Forms.MenuItem
Private WithEvents menuItem_wordwrap As System.Windows.Forms.MenuItem
Private WithEvents menuItem_tmdt As System.Windows.Forms.MenuItem
Private WithEvents menuItem_selectAll As System.Windows.Forms.MenuItem
Private menuItem6 As System.Windows.Forms.MenuItem
Private menuItem1 As System.Windows.Forms.MenuItem
Private WithEvents menuItem_del As System.Windows.Forms.MenuItem
Private WithEvents menuItem_paste As System.Windows.Forms.MenuItem
Private WithEvents menuItem_copy As System.Windows.Forms.MenuItem
Private WithEvents menuItem_cut As System.Windows.Forms.MenuItem
Private WithEvents menuItem_undo As System.Windows.Forms.MenuItem
Private menuItem13 As System.Windows.Forms.MenuItem
Private WithEvents menuItem_exit As System.Windows.Forms.MenuItem
Private WithEvents menuItem_print As System.Windows.Forms.MenuItem
Private WithEvents menuItem_pagesetup As System.Windows.Forms.MenuItem
Private WithEvents menuItem_saveas As System.Windows.Forms.MenuItem
Private WithEvents menuItem_save As System.Windows.Forms.MenuItem
Private WithEvents menuItem_open As System.Windows.Forms.MenuItem
Private WithEvents menuitem_new As System.Windows.Forms.MenuItem
Private menuItem_format As System.Windows.Forms.MenuItem
Private menuItem_edit As System.Windows.Forms.MenuItem
Private menuItem_file As System.Windows.Forms.MenuItem
Private mainMenu1 As System.Windows.Forms.MainMenu
Public Sub New()
InitializeComponent()
End Sub 'New
Protected Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub 'Dispose
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.pageSetupDialog1 = New System.Windows.Forms.PageSetupDialog
Me.menuItem_print = New System.Windows.Forms.MenuItem
Me.menuItem_pagesetup = New System.Windows.Forms.MenuItem
Me.colorDialog1 = New System.Windows.Forms.ColorDialog
Me.menuItem_wordwrap = New System.Windows.Forms.MenuItem
Me.menuItem_tmdt = New System.Windows.Forms.MenuItem
Me.menuItem_paste = New System.Windows.Forms.MenuItem
Me.menuItem_saveas = New System.Windows.Forms.MenuItem
Me.menuItem_file = New System.Windows.Forms.MenuItem
Me.menuitem_new = New System.Windows.Forms.MenuItem
Me.menuItem_open = New System.Windows.Forms.MenuItem
Me.menuItem_save = New System.Windows.Forms.MenuItem
Me.menuItem4 = New System.Windows.Forms.MenuItem
Me.menuItem13 = New System.Windows.Forms.MenuItem
Me.menuItem_exit = New System.Windows.Forms.MenuItem
Me.menuItem_cut = New System.Windows.Forms.MenuItem
Me.menuItem_selectAll = New System.Windows.Forms.MenuItem
Me.mainMenu1 = New System.Windows.Forms.MainMenu(Me.components)
Me.menuItem_edit = New System.Windows.Forms.MenuItem
Me.menuItem_undo = New System.Windows.Forms.MenuItem
Me.menuItem1 = New System.Windows.Forms.MenuItem
Me.menuItem_copy = New System.Windows.Forms.MenuItem
Me.menuItem_del = New System.Windows.Forms.MenuItem
Me.menuItem6 = New System.Windows.Forms.MenuItem
Me.menuItem_format = New System.Windows.Forms.MenuItem
Me.menuItem_font = New System.Windows.Forms.MenuItem
Me.menuItem_color = New System.Windows.Forms.MenuItem
Me.menuItem_Aboutme = New System.Windows.Forms.MenuItem
Me.statusBar1 = New System.Windows.Forms.StatusBar
Me.textBox_pad = New System.Windows.Forms.TextBox
Me.fontDialog1 = New System.Windows.Forms.FontDialog
Me.openFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.saveFileDialog1 = New System.Windows.Forms.SaveFileDialog
Me.printDialog1 = New System.Windows.Forms.PrintDialog
Me.SuspendLayout()
'
'menuItem_print
'
Me.menuItem_print.Index = 6
Me.menuItem_print.Shortcut = System.Windows.Forms.Shortcut.CtrlP
Me.menuItem_print.Text = "Print..."
'
'menuItem_pagesetup
'
Me.menuItem_pagesetup.Index = 5
Me.menuItem_pagesetup.Text = "Page Setup..."
'
'menuItem_wordwrap
'
Me.menuItem_wordwrap.Index = 0
Me.menuItem_wordwrap.Text = "Word Wrap"
'
'menuItem_tmdt
'
Me.menuItem_tmdt.Index = 8
Me.menuItem_tmdt.Shortcut = System.Windows.Forms.Shortcut.F5
Me.menuItem_tmdt.Text = "Time/Date"
'
'menuItem_paste
'
Me.menuItem_paste.Index = 4
Me.menuItem_paste.Text = "Paste Ctrl+V"
'
'menuItem_saveas
'
Me.menuItem_saveas.Index = 3
Me.menuItem_saveas.Text = "Save As..."
'
'menuItem_file
'
Me.menuItem_file.Index = 0
Me.menuItem_file.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuitem_new, Me.menuItem_open, Me.menuItem_save, Me.menuItem_saveas, Me.menuItem4, Me.menuItem_pagesetup, Me.menuItem_print, Me.menuItem13, Me.menuItem_exit})
Me.menuItem_file.Text = "File"
'
'menuitem_new
'
Me.menuitem_new.Index = 0
Me.menuitem_new.Shortcut = System.Windows.Forms.Shortcut.CtrlN
Me.menuitem_new.Text = "New"
'
'menuItem_open
'
Me.menuItem_open.Index = 1
Me.menuItem_open.Shortcut = System.Windows.Forms.Shortcut.CtrlO
Me.menuItem_open.Text = "Open"
'
'menuItem_save
'
Me.menuItem_save.Index = 2
Me.menuItem_save.Shortcut = System.Windows.Forms.Shortcut.CtrlS
Me.menuItem_save.Text = "Save..."
'
'menuItem4
'
Me.menuItem4.Index = 4
Me.menuItem4.Text = "-"
'
'menuItem13
'
Me.menuItem13.Index = 7
Me.menuItem13.Text = "-"
'
'menuItem_exit
'
Me.menuItem_exit.Index = 8
Me.menuItem_exit.Text = "Exit"
'
'menuItem_cut
'
Me.menuItem_cut.Index = 2
Me.menuItem_cut.Text = "Cut Ctrl+X"
'
'menuItem_selectAll
'
Me.menuItem_selectAll.Index = 7
Me.menuItem_selectAll.Shortcut = System.Windows.Forms.Shortcut.CtrlA
Me.menuItem_selectAll.Text = "Select All"
'
'mainMenu1
'
Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem_file, Me.menuItem_edit, Me.menuItem_format, Me.menuItem_Aboutme})
'
'menuItem_edit
'
Me.menuItem_edit.Index = 1
Me.menuItem_edit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem_undo, Me.menuItem1, Me.menuItem_cut, Me.menuItem_copy, Me.menuItem_paste, Me.menuItem_del, Me.menuItem6, Me.menuItem_selectAll, Me.menuItem_tmdt})
Me.menuItem_edit.Text = "Edit"
'
'menuItem_undo
'
Me.menuItem_undo.Index = 0
Me.menuItem_undo.Text = "Undo Ctrl+Z"
'
'menuItem1
'
Me.menuItem1.Index = 1
Me.menuItem1.Text = "-"
'
'menuItem_copy
'
Me.menuItem_copy.Index = 3
Me.menuItem_copy.Text = "Copy Ctrl+C"
'
'menuItem_del
'
Me.menuItem_del.Index = 5
Me.menuItem_del.Text = "Delete Del"
'
'menuItem6
'
Me.menuItem6.Index = 6
Me.menuItem6.Text = "-"
'
'menuItem_format
'
Me.menuItem_format.Index = 2
Me.menuItem_format.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem_wordwrap, Me.menuItem_font, Me.menuItem_color})
Me.menuItem_format.Text = "Format"
'
'menuItem_font
'
Me.menuItem_font.Index = 1
Me.menuItem_font.Text = "Font..."
'
'menuItem_color
'
Me.menuItem_color.Index = 2
Me.menuItem_color.Text = "Color..."
'
'menuItem_Aboutme
'
Me.menuItem_Aboutme.Index = 3
Me.menuItem_Aboutme.Text = "About me"
'
'statusBar1
'
Me.statusBar1.Location = New System.Drawing.Point(0, 233)
Me.statusBar1.Name = "statusBar1"
Me.statusBar1.Size = New System.Drawing.Size(330, 20)
Me.statusBar1.TabIndex = 2
Me.statusBar1.Text = "05172411"
'
'textBox_pad
'
Me.textBox_pad.Dock = System.Windows.Forms.DockStyle.Fill
Me.textBox_pad.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!)
Me.textBox_pad.HideSelection = False
Me.textBox_pad.Location = New System.Drawing.Point(0, 0)
Me.textBox_pad.Multiline = True
Me.textBox_pad.Name = "textBox_pad"
Me.textBox_pad.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.textBox_pad.Size = New System.Drawing.Size(330, 253)
Me.textBox_pad.TabIndex = 1
'
'saveFileDialog1
'
Me.saveFileDialog1.FileName = "doc1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(330, 253)
Me.Controls.Add(Me.statusBar1)
Me.Controls.Add(Me.textBox_pad)
Me.Menu = Me.mainMenu1
Me.Name = "Form1"
Me.Text = "Untiteled-Notepad"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub 'InitializeComponent
Protected Sub menuItem_wordwrap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_wordwrap.Click
If textBox_pad.WordWrap = True Then
textBox_pad.WordWrap = False
Else
textBox_pad.WordWrap = True
End If
End Sub 'menuItem_wordwrap_Click
Protected Sub menuItem_Aboutme_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim note As MessageBox
MessageBox.Show("05172411")
End Sub 'menuItem_aboutpad_Click
Protected Sub menuItem_del_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_del.Click
textBox_pad.SelectedText = ""
End Sub 'menuItem_del_Click
Protected Sub textBox_pad_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles textBox_pad.TextChanged
If textBox_pad.SelectedText = "" Then
menuItem_cut.Enabled = True
menuItem_copy.Enabled = True
menuItem_del.Enabled = True
Else
menuItem_cut.Enabled = False
menuItem_copy.Enabled = False
menuItem_del.Enabled = False
End If
End Sub 'textBox_pad_TextChanged
Protected Sub menuItem_paste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_paste.Click
textBox_pad.Paste()
End Sub 'menuItem_paste_Click
Protected Sub menuItem_copy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_copy.Click
textBox_pad.Copy()
End Sub 'menuItem_copy_Click
Protected Sub menuItem_cut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_cut.Click
textBox_pad.Cut()
End Sub 'menuItem_cut_Click
Protected Sub menuItem_undo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_undo.Click
textBox_pad.Undo()
End Sub 'menuItem_undo_Click
Protected Sub menuItem_pagesetup_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_pagesetup.Click
Dim doc As New System.Drawing.Printing.PrintDocument()
doc.DocumentName = textBox_pad.Text
pageSetupDialog1.Document = doc
pageSetupDialog1.ShowDialog()
End Sub 'menuItem_pagesetup_Click
Protected Sub menuItem_color_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_color.Click
colorDialog1.ShowDialog()
textBox_pad.ForeColor = colorDialog1.Color
End Sub 'menuItem_color_Click
Protected Sub menuItem_font_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_font.Click
fontDialog1.ShowDialog()
textBox_pad.Font = fontDialog1.Font
End Sub 'menuItem_font_Click
Protected Sub menuItem_print_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_print.Click
printDialog1.AllowPrintToFile = True
Dim doc As New System.Drawing.Printing.PrintDocument()
doc.DocumentName = textBox_pad.Text
printDialog1.Document = doc
printDialog1.ShowDialog()
doc.Print()
End Sub 'menuItem_print_Click
Protected Sub menuItem_selectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_selectAll.Click
textBox_pad.SelectAll()
End Sub 'menuItem_selectAll_Click
Protected Sub menuItem_tmdt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_tmdt.Click
textBox_pad.Text = textBox_pad.Text + DateTime.Now.ToLongTimeString() + DateTime.Now.ToLongDateString()
End Sub 'menuItem_tmdt_Click
Protected Sub menuItem_saveas_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_saveas.Click
saveFileDialog1.ShowDialog()
Dim name As String = saveFileDialog1.FileName
Dim value1 As String = textBox_pad.Text
Dim sout As New StreamWriter(name)
sout.WriteLine(value1)
sout.Flush()
Me.Text = name
sout.Close()
End Sub 'menuItem_saveas_Click
Protected Sub menuitem_new_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuitem_new.Click
textBox_pad.Text = ""
Me.Text = "Untiteled-Notepad"
End Sub 'menuitem_new_Click
Protected Sub menuItem_exit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_exit.Click
Me.Close()
End Sub 'menuItem_exit_Click
Protected Sub menuItem_save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_save.Click
Dim name As String
Dim value1 As String = textBox_pad.Text
If Me.Text = "Untiteled-Notepad" Then
saveFileDialog1.ShowDialog()
name = saveFileDialog1.FileName
Else
name = Me.Text
End If
Dim sout As New StreamWriter(name)
sout.WriteLine(value1)
sout.Flush()
Me.Text = name
sout.Close()
End Sub 'menuItem_save_Click
Protected Sub menuItem_open_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_open.Click
openFileDialog1.ShowDialog()
Dim name As String = openFileDialog1.FileName
Dim contain As System.IO.Stream = openFileDialog1.OpenFile()
Dim m_streamReader As New StreamReader(contain)
Dim str As String = ""
Dim check As Integer
check = m_streamReader.Read()
While check <> -1
str = str + Microsoft.VisualBasic.ChrW(check)
check = m_streamReader.Read()
End While
textBox_pad.Text = str
Me.Text = name
contain.Close()
End Sub 'menuItem_open_Click
'Entry point which delegates to C-style main Private Function
' Public Overloads Shared Sub Main()
' Main(System.Environment.GetCommandLineArgs())
' End Sub
Public Overloads Shared Sub Main(ByVal args() As String)
Application.Run(New Form1())
End Sub
Friend WithEvents menuItem_Aboutme As System.Windows.Forms.MenuItem 'Main
End Class 'Form1
End Namespace 'notepad
and as you will have noticed vb.net is definately not my strong point THANK YOU
Luna Harp
|
|
|
|
|
I've repaired ur project. Couldn't figure out why it didnt work. SO I created a new project I started to paste ur code. I got it working.
You still have some problems to correct to it but I guess u know it already and I dont think that u'll have any problem to correct them.
I can send you a zip with the new project on ur email address.
You can respond at: ludo.deraed@fox.com
I'll explain you in details why it could't show the components.
-- modified at 10:01 Tuesday 5th December, 2006
Ludo
|
|
|
|
|
Dear friends...
ı had written a code at Wincc...Its
dim box as integer
dim fener
Set fener=ScreenItems("lorry")
...
for box=1 to 5
Fener.left=Fener.left-10
next
end function
...
but editor says its wrong...
so whats the differ VBS and Visual Basic 6
|
|
|
|
|
First, what is "Wincc"?
Next, what's the error that you're getting and on which line?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dear Kreskowiak
Wincc is a type of automation programme..It's of Sıemens....We use it for communicate PLC-COMPUTER and another electric and electronic devices....In that programme u draw some electrical devices and then u write some codes for give them moveable actions..
i show u a example picture from it..
http://www.resimekle.com/yukle/view/91764
|
|
|
|
|
How to read data from excel sheet
and how to insert it into microsoft sqlserver 2000.
|
|
|
|
|
|
i have tried much on for sorting a simple datagrid but yup!
Dim DV As DataView
Dim ds1 As DataSet
DV = ds1.Tables("tbl_emps").DefaultView
Me.DataGrid1.DataSource() = DV
Me.DataGrid1.DataBind()
this is the code what i have written..
the error is :
Object reference not set to an instance of an object.
can anyone help me out please
tirumal
|
|
|
|
|
Does anybody knows how to play an swf file inside a .NET form.
I tried to use the flash ocx component but it says failed to load activeX.
Is there any other means?
Thanks in advance,
Phil
|
|
|
|
|
You could use a webbrowser control and navigate to the swf file
Add the WebBrowser control to your form and call the navigate method from code
i.e. WebBrowser1.navigate("pathto swf").
Should work as long as a working swf player is registered with IE.
|
|
|
|
|
I need one example program for Keypress event.that is put on Ascii values.so pls tel me one textbox to another textbox.pls tell me the exmple program in VB.Net
Thanking You
somasundaram G
|
|
|
|
|
///6.0
If KeyAscii = 8 Then
Exit Sub
End If
If KeyAscii = 46 Then
If InStr(txtRate.Text, Chr(46)) = 0 Then
Exit Sub
Else
KeyAscii = 0
End If
End If
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
///.Net 2005
If Asc(e.KeyChar) = 8 Then
Exit Sub
End If
If Asc(e.KeyChar) = 46 Then
If InStr(txtRate.Text, Chr(46)) = 0 Then
Exit Sub
Else
e.Handled = True
End If
End If
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub
////
this is for trapping only numbersand 1 decimal point in a textbox on the keypress event. hope it helps
Love makes the world go round
|
|
|
|
|
All you have to do is handle the KeyDown event of the TextBox. I have no idea what you want to do with the Ascii value, so...
Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
' The keycode is in e.Keycode.
Console.WriteLine("KeyCode value: " & e.KeyCode )
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
vs.net ( vb ) 2005
I have a form which when loaded adds x number of checkboxes. In the function i have written to add the checkboxes i have included the folling lines
ACheckBox.Tag = Index
' Index being the number of the current Checkbox
AddHandler aCheckBox.CheckChanged, AddressOf MyClickHandler
How in the 'MyClickHandler' sub will i be able to find the index of the aCheckBox that was clicked ?
Thanks for any help
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Sub MyClickHandler(sender as object,e as system.eventargs)
sender.tag ' checkbox that was checked.
end sub
|
|
|
|
|
To expand on the other posters answer... When you create the checkboxs in your code, set the Tag property of each CheckBox to the number you want. You can then look at that property in the ClickHandler code to figure out which one was clicked.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have some strings which I want to replace them with single quotes so that I can use them as arguments that are passed to a sql query.
Example, string variable Name:
"Peter John"
Should be replaced with single quotes
'Peter John'
so name should contain only 'Peter John'
Is there any possible way to do this.
I have tried doing the following:
name.replace(34, 39) 'unicode characters, did seem to work.
name.replace(" "" ","'") 'Not work either
I have been told to use the escape characters:
name.replace('\"','\'')' Syntax error expression expected
Many thanks for any help,
Steve
|
|
|
|
|
please tell us why u intend to do this
|
|
|
|
|
steve_rm wrote: I have been told to use the escape characters:
name.replace('\"','\'')' Syntax error expression expected
As you asked in the C# forum, you got C# code. You can't use escape sequences in VB.
---
b { font-weight: normal; }
|
|
|
|
|
Not totaly sure I understand your request, but if the value of 'name' variable contains the double quote, name.replace("""","'") should work.
Phil
|
|
|
|
|
hi,
Any one have an idea about making activation software.
Thanks,
|
|
|
|
|
Could you be more specific?
|
|
|
|
|
Hi,
I want to make a software for trail use of 30 days or 15 days etc.
Please give me an idea.
Thanks,
|
|
|
|
|
They way I would do it is, after you install your program, store the date that your program was installed for the first time, and use DateTime function to add the days since ran. Then, if your program has been installed for 30 days, set a Boolean value that locks the interface (or however you want to discontinue access to your program).
|
|
|
|
|
Where would you store the values?
Usual user settings locations would be easy enough to find eg: isolated storage.
A key in the registry? You could create an algorithm for generating a key in the registry and just store the date with no other identifying informaiton. And then just leave the key there until a full version was installed.
|
|
|
|