
dynamic_sysop
Leaders
-
Posts
1044 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by dynamic_sysop
-
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = "." Then e.Handled = True TextBox1.SelectedText = "," End If End Sub
-
it certainly looks like profanity cuz it's got a t as well as the wat bit :cool: used to get that on irc with s c u n t h o r p e ( and thats only a town in the uk :-\ ) lol
-
Not sure if this will be classed as Ok for the Code section , but here ya go . I've noticed on a few boards that people have been asking about the " BeforeNavigate2 " event not triggering when using the AxWebBrowser control , so i decided to tackle the problem and here's the result : Private WithEvents doc As SHDocVw.DWebBrowserEvents_Event '/// doc will handle all the events for brWeb now... Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim b As Object = brWeb.Application doc = DirectCast(b, SHDocVw.WebBrowser_V1) '///set doc as the active handler for brWeb's events. End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click brWeb.Navigate("http://google.com") '///lets navigate to a website. End Sub Private Sub doc_BeforeNavigate(ByVal URL As String, ByVal Flags As Integer, ByVal TargetFrameName As String, ByRef PostData As Object, ByVal Headers As String, ByRef Cancel As Boolean) Handles doc.BeforeNavigate MessageBox.Show(URL) '/// check that before navigate now works. End Sub Private Sub doc_StatusTextChange(ByVal [Text] As String) Handles doc.StatusTextChange Label1.Text = Text '///show the status text in a label. End Sub Private Sub doc_TitleChange(ByVal [Text] As String) Handles doc.TitleChange MyBase.Text = Text '/// set the form's caption to the current url End Sub it may help a few people atleast :) webbrowser.zip
-
Using CBN_CLOSEUP to give another Combobox focus
dynamic_sysop
replied to viatorg's topic in General
why not do something like this : Private Sub ComboBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ComboBox1.MouseDown If ComboBox1.SelectedIndex <> -1 Then If e.Button = MouseButtons.Left Then ComboBox2.Focus() End If End If End Sub Private Sub ComboBox2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ComboBox2.MouseUp If ComboBox1.SelectedIndex <> -1 Then '/// add any code here to retrieve the combo item from ComboBox1. ComboBox1.SelectedIndex = -1 End If End Sub -
i think he's after the actuall OS's serial number ( the key ) and i dont think it can be done , but i guess it may depend on the OS :-\
-
Opera Browser - GetClassName!
dynamic_sysop
replied to jesus4u's topic in Interoperation / Office Integration
nope , but even microsoft's api spy++ doesnt get the text of that -
Opera Browser - GetClassName!
dynamic_sysop
replied to jesus4u's topic in Interoperation / Office Integration
with your opera browser opened up try this : Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Integer, ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As Integer = FindWindow("OpWindow", vbNullString) Dim s As System.Text.StringBuilder = New System.Text.StringBuilder(255) GetClassName(x, s, s.Capacity) MessageBox.Show("the opera browser's hwnd is: " & x & Chr(13) _ & "the window name is: " & s.ToString) End Sub :) -
VB 6.0 to .NET upgrade (Excel questions)
dynamic_sysop
replied to Mortious's topic in Interoperation / Office Integration
yes it should , that's also for excel 97 / 2000 etc... -
VB 6.0 to .NET upgrade (Excel questions)
dynamic_sysop
replied to Mortious's topic in Interoperation / Office Integration
here's a quick example i put together , hope it helps. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim oDialog As New OpenFileDialog() oDialog.Filter = "Excel files|*.xls" oDialog.ShowDialog() Dim objExcel As New Excel.Application() Dim objBook As Excel.Workbook = objExcel.Workbooks.Open(oDialog.FileName) Dim objSheet As Excel.Worksheet = objBook.Worksheets.Item("Sheet1") Dim x As Integer Try For x = 1 To objSheet.UsedRange.Count MessageBox.Show(objSheet.UsedRange(x).value) Next Catch ex As Exception MessageBox.Show(ex.Message) Finally objSheet.Delete() objBook.Application.Quit() objExcel.Application.Quit() objSheet = Nothing objBook = Nothing objExcel = Nothing End Try End Sub thats using excel 10.0 object library btw. -
i've put a sample together for you , it may be easier , because certain chars dont show to good on here :-\windowsapplication19.zip
-
you need a : between OLEDB and Database ( it wont show up in here cuz it thinks it's an icon Dim strConnect As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C : \db3.mdb;Jet OLEDB : Database Password=myPassword;User ID=Admin;Persist Security Info=True" without the space between OLEDB : Database
-
grrrr at how the vb code function messes up code :mad: Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db3.mdb;Jet OLEDB:Database Password=password here;User ID=Admin;Persist Security Info=True" see if this shows :-\
-
Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db3.mdb;Jet OLEDB:Database Password="your password";User ID=Admin;Persist Security Info=True" eg : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db3.mdb;Jet OLEDB:Database Password=dynamic_sysop;User ID=Admin;Persist Security Info=True" Dim Command As String = "SELECT * FROM Table1" OpenAccessFile(Connection, Command) End Sub Private Sub OpenAccessFile(ByVal strConnection As String, ByVal strCommand As String) Try Dim objDbConnection As New OleDbConnection(strConnection) objDbConnection.Open() '///open a new connection. Dim objCommand As New OleDbCommand(strCommand, objDbConnection) Dim objAdaptor As OleDbDataAdapter objAdaptor = New OleDbDataAdapter(objCommand) Dim objDataSet As New DataSet() objAdaptor.Fill(objDataSet, "Table1") DataGrid1.DataSource = objDataSet.Tables("Table1") '///fill a datagrid with the recordset objDbConnection.Close() objCommand.Dispose() objAdaptor.Dispose() objDataSet.Dispose() Catch ex As Exception MsgBox(ex.Message) End Try End Sub
-
you can make a new Class project , remove the class form , then go to project, add Component. add a new Component Class. then you can add controls / functions etc... compile the new class open a new standard project right-click on the toolbox and customise toolbox click the .net framework components tab click browse , to locate your new class . dll it will be added to your toolbox , then you can add it like any other items ( such as MainMenu etc... ) here's an example of a class i quickly bunged together : in the class project : Public Class Component1 Inherits System.ComponentModel.Component #Region " Component Designer generated code " Public Sub New(Container As System.ComponentModel.IContainer) MyClass.New() 'Required for Windows.Forms Class Composition Designer support Container.Add(me) End Sub Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Component overrides dispose to clean up the component list. Protected Overloads Overrides 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 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(17, 17) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" End Sub #End Region Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("test!") End Sub End Class in your form ( once you've added the class to the toolbox ) Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides 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 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Component11 As ClassLibrary3.Component1 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.Button1 = New System.Windows.Forms.Button() Me.Component11 = New ClassLibrary3.Component1(Me.components) Me.SuspendLayout() ' 'Button1 ' Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(544, 286) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1}) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Component11.Button1_Click(sender, e) End Sub End Class if you want to use a "user control" you can do pretty much the same.
-
yes it's supposed to be spaces not the < href stuff , thats how it converted on the thread :-\ http://google.com http://yahoo.com http://msn.com with spaces.
-
if you only want to be able to navigate to the sites and retrieve the source of them sites / also be able to download images etc... why not use System.Net.WebClient ? here's an example , just downloading 3 sites , with a 100 millisecond pause : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strUrls() As String = "http://google.com [url]http://yahoo.com[/url] [url]http://msn.com[/url]".Split(" ") Dim x(3) As System.Net.WebClient Dim i As Integer For i = 0 To 2 x(i) = New System.Net.WebClient() Dim st As New IO.StreamReader(x(i).OpenRead(strUrls(i))) MsgBox(st.ReadToEnd) Threading.Thread.Sleep(100) st.Close() x(i).Dispose() Next End Sub
-
e.Handled doesnt do anything in a textbox's keyup / keydown ( well atleast not on quite a lot of key presses , you can handle / divert stuff though on them events , like moving focus or triggering something else.
-
Access object properties in another class
dynamic_sysop
replied to Chong's topic in Visual Basic .NET
try this ... in Form1 ( the form that holds the datagrid you want to fill ) : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm2 As New clsComputer() AddOwnedForm(frm2) frm2.Show() End Sub in form2 ( whatever the class is you want to use to open the database ) : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/MyDb.mdb" Dim Command As String = "SELECT * FROM Table1" Dim objConnection As New OleDb.OleDbConnection(Connection) '/// make a new connection. Dim objCommand As New OleDb.OleDbCommand(Command, objConnection) Dim objAdaptor As OleDb.OleDbDataAdapter objAdaptor = New OleDb.OleDbDataAdapter(objCommand) Dim objDataSet As New DataSet() objAdaptor.Fill(objDataSet, "Table1") '////////// try this below////////////////////////// Dim frmMain As Form1 = Owner '//////// try this <<<<< frmMain.DataGrid1.DataSource = objDataSet.Tables("Table1") '/// add the table to a datagrid. '////////////////////////////////////////// objDataSet.Dispose() objAdaptor.Dispose() objCommand.Dispose() objConnection.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub -
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MessageBox.Show(testFunc("Test")) End Sub Public Function testFunc(ByVal strString As String) As String Return strString '/// return the value. End Function or using your original function : Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox(testFunc) '// will show Test. End Sub Public Function testFunc() As String testFunc = "Test" End Function
-
personally i wouldn't persuade someone to use vb5 / vb6 to build an application over vb.net , as vb.net is far better :) not sure if you can use a set up program like "Inno" and then just specify for it to include the .net framework , it should then register it on install
-
as mutant was saying Application.ExecutablePath , that returns the path and exe name all in 1 line : MessageBox.Show(Application.ExecutablePath) to get just the start up directory ( minus the exe name ) this works : MessageBox.Show(Application.StartupPath)
-
try this : Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb;" Dim Conn As New OleDb.OleDbConnection(sConnString) Try Dim sCommand As String = "Select * From Table1" Conn.Open() Dim Command As New OleDb.OleDbCommand(sCommand, Conn) Dim reader As OleDb.OleDbDataReader reader = Command.ExecuteReader Dim x As Integer For x = 0 To reader.FieldCount - 1 MessageBox.Show(reader.GetName(x)) '/// the names of your fields. Next Catch ex As Exception MessageBox.Show(ex.Message) Finally Conn.Close() End Try End Sub it may help.
-
if there is text in a textbox you can use the SelectionStart property , eg: Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Down Then TextBox2.Focus() TextBox2.SelectionStart = Len(TextBox2.Text) '// go to end of text. End If End Sub
-
also you can use a richtextbox to open the file with a very small amount of code : Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If IO.File.Exists("C:\test.txt") Then RichTextBox1.LoadFile("C:\test.txt", RichTextBoxStreamType.PlainText) End If End Sub
-
well you can include a textfile in your project , but it will get stored in the program's folder anyway , but here's how to read from a textfile on your HD to a textbox : Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim f As IO.File Dim path As String = "C:\test.txt" If f.Exists(path) Then '/// check if the text file exsists. Dim sRead As IO.StreamReader = New IO.StreamReader(New IO.FileStream(path, IO.FileMode.Open)) While Not sRead.Peek TextBox2.AppendText(sRead.ReadLine & Environment.NewLine) '/// read the text file 1 line at a time , in to a textbox. End While sRead.Close() Else MessageBox.Show("oops check you put the correct file path!") End If End Sub