Jump to content
Xtreme .Net Talk

dynamic_sysop

Leaders
  • Posts

    1044
  • Joined

  • Last visited

Everything posted by dynamic_sysop

  1. if you want to load the project ( as in open the exe and run it ) from vb6 , you can either use the " Shell " command , or the ShellExecute api. eg: Private Sub Command1_Click() Shell "C:\your exe location", vbNormalFocus End Sub or Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Const SW_SHOWDEFAULT As Long = 10 Private Sub Command1_Click() ShellExecute 0, "open", "C:\your exe location", vbNullString, vbNullString, SW_SHOWDEFAULT End Sub
  2. it's better to use mciSendString to play the wav , you have much more control :) eg: Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer '/// just below windows generated code ^^^^ '////////////////////////////////////////////////////////// Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As Integer = mciSendString("Open D:\Knock.Wav type waveaudio alias Knock", Nothing, Nothing, Nothing) Dim i As Integer = mciSendString("Play Knock", Nothing, Nothing, Nothing) '///opens the wav and plays it ^^^^ '///then to close it.... i = mciSendString("Stop Knock", Nothing, Nothing, Nothing) '///this stops it when it's playing ^^^^ End Sub hope it helps.
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim W As String = ListBox1.SelectedItem MessageBox.Show(W) End Sub ;)
  4. nope just use System.Environment.TickCount no need for dll import :)
  5. objSheet.Range("A1").Copy(objSheet.Range("A2")) '/// that copies A1 and puts it to A2 :)
  6. in Form1 : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim you As New InkPad() Me.AddOwnedForm(you) '/// add this line. you.Show() End Sub in the form " InkPad " Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objCont As Form1 = Me.Owner '/// add = Me.Owner objCont.rtxtComments.SelectedText = "some text from me to Form1!" End Sub
  7. you could create a registry location , then allow the user to set the path for the file through that , eg: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim reg As Microsoft.Win32.Registry Dim key As Microsoft.Win32.RegistryKey = reg.CurrentUser Try If key.OpenSubKey(Application.ProductName, True) Is Nothing Then key.CreateSubKey(Application.ProductName).SetValue("DbLocation", "C:\MyDb.mdb") Else MessageBox.Show("key exsists!") '/// dont create it again. '/// then you can write a new value to it, eg : key.OpenSubKey(Application.ProductName, True).SetValue("DbLocation", "C:\newlocation.mdb") End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
  8. CInt ? eg : Private Const WS_EX_TRANSPARENT As Integer = CInt(&H20&)
  9. here's an example of making 3 basic picturebox's and handling them : Private WithEvents picBox As PictureBox Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim pics(2) As PictureBox Dim x As Integer Dim i As Integer = 20 For x = 0 To UBound(pics) pics(x) = New PictureBox() With pics(x) .Tag = x .Location = New System.Drawing.Point(400, i) .BackColor = Color.Red .Visible = True Controls.Add(pics(x)) AddHandler pics(x).Click, AddressOf picBox_Click End With i += 60 Next End Sub Private Sub picBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picBox.Click MessageBox.Show(sender.tag) End Sub
  10. Select Case KeyPressed Case Keys.Alt , Keys.S '/// do stuff Return True End Select Return base.processcmdkey (KeyMsg, KeyPressed)
  11. private void button1_Click(object sender, System.EventArgs e) { Form2 frm=new Form2(); this.AddOwnedForm(frm); frm.StartPosition=System.Windows.Forms.FormStartPosition.CenterScreen; frm.Show(); Rectangle r=new Rectangle(this.Location,this.Size); frm.Location = new Point(r.Width /2,r.Height /2); }
  12. Hi just a quick snippet of code i made for the purpose of unloading forms in vb.net ( those other forms that are open still when closing down your main Form / exiting. in a Module : Module Module1 Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private Const WM_CLOSE As Integer = CInt(&H10) Public Function CloseForms(ByVal forms() As String) As Boolean Dim x As Integer Dim i As Integer For i = LBound(forms) To UBound(forms) x = FindWindow(vbNullString, forms(i)) If Not x = 0 Then PostMessage(x, WM_CLOSE, 0, 0) '/// close the Form. End If Next Return True End Function End Module in the Main Form ( eg: Form1 ) : Private frms() As Form = {New Form2(), New Form3()} '/// all forms in the Application apart from Form1. Private frmNames(1) As String '/// this will house the window caption of the forms. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer For i = LBound(frms) To UBound(frms) frmNames(i) = frms(i).Text Next End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If CloseForms(frmNames) = True Then Me.Close() End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click frms(0).Show() frms(1).Show() MyBase.BringToFront() End Sub i have included a small demo source : closing forms.zip
  13. why not use a Sub_Main to start your app , instead of Form1? then Form1 will never show unless you tell it to :)
  14. log.Write("<font color=""#c0c0c0>""Added text:"" & textbox1.text) you have a { where there shouldnt be 1 , also you shouldn't enclose the textbox1.text in brackets , if you want to add the text from inside it.
  15. here's a simple example i made just for you :) , i've included a demo source code zip to make it easier to go through . Private WithEvents mnuItems As MenuItem Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler MenuItem2.MeasureItem, AddressOf mnuItems_MeasureItem AddHandler MenuItem3.MeasureItem, AddressOf mnuItems_MeasureItem AddHandler MenuItem2.DrawItem, AddressOf mnuItems_DrawItem AddHandler MenuItem3.DrawItem, AddressOf mnuItems_DrawItem End Sub Private Sub mnuItems_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles mnuItems.MeasureItem With e .ItemHeight = 20 .ItemWidth = 100 End With End Sub Private Sub mnuItems_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles mnuItems.DrawItem If Not e.State = 256 Then With e.Graphics .FillRectangle(New SolidBrush(Color.Blue), e.Bounds.X + 20, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height) .DrawRectangle(New Pen(Color.Blue), e.Bounds.X + 20, e.Bounds.Y, e.Bounds.Width - 21, e.Bounds.Height - 1) .DrawString(sender.text, New Font("Tahoma", 10, FontStyle.Regular), New SolidBrush(Color.White), 22, e.Bounds.Y + 3) .DrawImage(ImageList1.Images.Item(0), e.Bounds.X + 1, e.Bounds.Y + 3) End With Else With e.Graphics .FillRectangle(New SolidBrush(Color.LightBlue), e.Bounds.X + 20, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height) .DrawRectangle(New Pen(Color.Gray), e.Bounds.X + 20, e.Bounds.Y, e.Bounds.Width - 21, e.Bounds.Height - 1) .DrawString(sender.text, New Font("Tahoma", 10, FontStyle.Regular), New SolidBrush(Color.White), 22, e.Bounds.Y + 3) .DrawImage(ImageList1.Images.Item(1), e.Bounds.X + 1, e.Bounds.Y + 3) End With End If End Sub windowsapplication21.zip
  16. yeah , you need to make the menu's " OwnerDraw " , then use an imagelist , then on the " Draw " and " Measure " subs of the menuitems , just use the graphics to create the menu / with icons. only a few lines of code and you are on the way :)
  17. dont know why :-\ because they both return the exact same values , try this : using System.Runtime.InteropServices; /// top of your code window. ////////////////////////////////////// [DllImport("kernel32.dll")] public static extern int GetTickCount(); /// below windows generated code^^^^ ////////////////////////////////////// private void button1_Click(object sender, System.EventArgs e) { MessageBox.Show(System.Environment.TickCount.ToString() + " " + GetTickCount().ToString()); } they both give the same values :) as does this vb6 example : Private Declare Function GetTickCount Lib "kernel32.dll" () As Long Private Sub Command1_Click() MsgBox GetTickCount End Sub
  18. private void button4_Click(object sender, System.EventArgs e) { MessageBox.Show(System.Environment.TickCount.ToString()); } :)
  19. i get the feeling that the * 's aint supposed to be there , but are just there to show which bit they want to extract eg: "hello . How are you there**I am Leanord**This world is beautiful" would be : "hello . How are you there I am Leanord This world is beautiful" and they want to find "I am Leanord" from the line ( but the line doesnt actually hold any * 's ) :-\
  20. if you know the phrase you are after then you can do this : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As String = "hello . How are you there I am Leanord This world is beautiful" Dim i As Integer = Len("I am Leanord") Dim s As String = x.Substring(InStr(x, "I") - 1, i) MessageBox.Show(s) End Sub
  21. regarding the picturebox stuff here's some changes that may help you : hwnd's : '/// in vb6 : picturebox1.HWnd '/// '/// in .Net : picturebox1.Handle.ToInt32() '/// '////////////////////////////////////// print ( text to picture box ) '/// in vb6 : picturebox1.Print " some text " '/// '/// in .Net : Dim g As Graphics = picturebox1.CreateGraphics() g.DrawString(" some text ", New Font("Tahoma", 10), New SolidBrush(Color.Red), 0, 2) g.Dispose() '//////////////////////////////////////
  22. i mean have a universal event in your mdi parent that handles the closing of all child windows ( then you will see when a child window closes / get it's value ) not the standard event which is in the child window. eg , when an mdi child ( say called Child1 ) closes / attempts to close , this sub ( in your mdi Parent form ) will handle it / see which child form is closing ... Private Sub frm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles frm.Closing Dim f As Form = sender '//// the MDI CHILD. MessageBox.Show("closing " & f.Name) End Sub
  23. are you sure the table " User " is there? i just tried your code on 1 of my db's ( calling Table1 ) and it worked fine : Imports System.Data.OleDb ' /// top of code page. '/////////////////////////// Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb" Dim mySelectQuery As String = "SELECT * FROM Table1" Dim myConnection As New OleDbConnection(myConnString) Dim myCommand As New OleDbCommand(mySelectQuery, myConnection) myConnection.Open() Dim myReader As OleDbDataReader myReader = myCommand.ExecuteReader() While myReader.Read() Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _ + myReader.GetString(1)) End While myReader.Close() myConnection.Close() End Sub
  24. you could create a handler for closing on your mdiParent form , eg : Private WithEvents frm As Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frmChild As New Form2() frmChild.MdiParent = Me.ActiveForm frmChild.Show() AddHandler frmChild.Closing, AddressOf frm_Closing '/// add any extra handlers that you would need here. End Sub Private Sub frm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles frm.Closing Dim f As Form = sender MessageBox.Show("closing " & f.Name) End Sub i'm sure it could be modified for an array of forms quite easily.
  25. MessageBox.Show(Environment.TickCount())
×
×
  • Create New...