Jump to content
Xtreme .Net Talk

dynamic_sysop

Leaders
  • Posts

    1044
  • Joined

  • Last visited

Everything posted by dynamic_sysop

  1. when ever i tried GetCharFromPosition it always returned the first item in the richtextbox , so here's a way i put together which may help. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As Integer x = RichTextBox1.SelectionStart() '/// where the cursor is in the rtf box's text RichTextBox1.SelectionLength = 1 '/// get the character at that position by making selectionlength 1. MessageBox.Show(RichTextBox1.SelectedText) End Sub
  2. you will need to use System.Security eg: Dim x As System.Security.Permissions.FileIOPermission Dim y As System.Security.Permissions.FileIOPermissionAttribute Dim j As System.Security.Permissions.SecurityPermission them are a few of the many security functions , i'm sure you'll find something you need in them.
  3. i did a search on msdn for EditState , this was the result i bet EditState is a function of an object / referenced item. eg: Dim Obj as New MyClass() With Obj .Add( "my text") .EditState = False '// maybe it's something like this. End With
  4. Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick MsgBox(ListView1.SelectedItems(0).SubItems(1).Text) '/// 1 represents the first subitem ( column 2 ) MsgBox(ListView1.SelectedItems(0).SubItems(2).Text) '/// 2 represents the second subitem ( column 3 ) End Sub
  5. yes , the 1 that the listbox is currently showing is the SelectedIndex this returns the item thats currently selected : Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If ListBox1.SelectedIndex < 0 Then Exit Sub ListBox1.SelectedItem = ListBox1.Items.Item(ListBox1.SelectedIndex) '/// put your chosen item where it says 1 MsgBox(ListBox1.SelectedItem) End Sub
  6. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.SelectedItem = ListBox1.Items.Item(1) '/// put your chosen item where it says 1 MsgBox(ListBox1.SelectedItem) End Sub
  7. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Select Case Screen.PrimaryScreen.Bounds.Width Case 800 MsgBox("you need your fonts set at 10") '/// set your font sizes here... Case 1024 MsgBox("you need your fonts set at 12") Case 1152 MsgBox("you need your fonts set at 14") Case 1280 MsgBox("you need your fonts set at 16") Case 1600 MsgBox("you need your fonts set at 18") End Select End Sub then you can decide which items to set the font sizes on.
  8. Private Sub ListView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp If ListView1.Items.Count = 0 Then Exit Sub TextBox4.Text = ListView1.SelectedItems(0).Text End Sub :)
  9. ok this will give you just the file name , eg "testing.txt" Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Dim dr As System.IO.Directory '/// directly use System.IO if you dont want to reference it at the top of form. Dim fPath As System.IO.Path'//// use that. Dim i As Integer For i = 0 To dr.GetFiles("C:\").Length() - 1 ListView1.Items.Add(fPath.GetFileName(dr.GetFiles("C:\").GetValue(i))) '//// add the items from the directory to a listview ^^^ Next End Sub
  10. [ vb ] your code [ / vb ] without the spaces ;)
  11. sorry maybe i should have been a little clearer , at the top of your form's code window , so you'd have something like this ( depending on your form's name ) Imports System.IO '///// very first line of code. Imports System.Text'/// ignore that 1 Public Class Form1 Inherits System.Windows.Forms.Form '/////////////////////////////////////////////////// alternatively you can do this : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dr As System.IO.Directory '/// directly use System.IO if you dont want to reference it at the top of form. Dim i As Integer For i = 0 To dr.GetFiles("C:\").Length() - 1 ListView1.Items.Add(dr.GetFiles("C:\").GetValue(i)) '//// add the items from the directory to a listview ^^^ Next End Sub
  12. here's an example i built to help someone on the other vb forum , it opens 5 instances of internet explorer , all with different urls. Private pr(5) As Process '//// in main part of form , so it's available to all subs^^^ '//////////// Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strUrl(5) As String Dim i As Integer strUrl(1) = "http://chat.msn.com" : strUrl(2) = "http://google.com" : strUrl(3) = "http://yahoo.com" strUrl(4) = "http://www.visualbasicforum.com/index.php?" : strUrl(5) = "http://www.xtremedotnettalk.com/index.php?" Try For i = 1 To 5 pr(i) = pr(i).Start("IEXPLORE", strUrl(i)) ListView1.Items.Add((pr(i).Handle.ToInt32)) '///add hwnd to listview. System.Threading.Thread.Sleep(500)'/// pause for half a second. Next Catch MessageBox.Show(Err.Number & " " & Err.Description, "Error!") End Try End Sub Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick Dim i As Integer = ListView1.SelectedItems(0).Index + 1 pr(i).CloseMainWindow() '/// close the instance of process. ListView1.Items.Remove(ListView1.Items(i - 1)) '/// remove process from list. End Sub hope this helps.
  13. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dr As Directory '////Imports System.IO must be at the top of your form. Dim i As Integer For i = 0 To dr.GetFiles("C:\").Length() - 1 ListView1.Items.Add(dr.GetFiles("C:\").GetValue(i)) '//// add the items from the directory to a listview ^^^ Next End Sub hope that helps a little :)
  14. how long is the text? just because you cant see it all it could be there still. i just added a line of text 182 chars long to 1 , like this : Private Sub CheckedListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CheckedListBox1.MouseDown MsgBox(CheckedListBox1.SelectedItem & Chr(10) & "length is :" & Len(CheckedListBox1.SelectedItem)) '/// check if the string is complete. End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str As String str = "abcdefghijklmnopqrstuvwxyz" str = str + str + str + str + str + str + str MsgBox(str.Length) CheckedListBox1.Items.Add(str)'/// add the string to the checkedlistbox End Sub
  15. if Cancel is False then the application can exit , if it's true then it wont. both them ways provide the same result anway thats the main thing:p
  16. streamreader / writer / filestream is 1000's of times better than the "old" vb methods of handling textfiles , it looks a lot tidier also and you can write / read with a lot less code + have more control over whats happening.
  17. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Dim MyFile As String = "C:\" & TextBox2.Text & ".txt" '//// make the file name / location to a string. WriteFile(MyFile) '/// write the info to the new file. End Sub Public Function WriteFile(ByVal FileName As String) Dim FileToStream As StreamWriter = New StreamWriter(New FileStream(FileName, FileMode.Create)) FileToStream.WriteLine("some text in to a new file!") FileToStream.Flush() FileToStream.Close() End Function
  18. ok i fixed it , i just give it a good test and mine highlights blue at the click of a button : Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click ListView1.Focus() ListView1.Items(3).Selected = True ListView1.Items(3).Focused = True End Sub hope this helps :)
  19. Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MsgBox("are you sure you want to quit", MsgBoxStyle.OKCancel, Application.ProductName) = MsgBoxResult.OK Then e.Cancel = False Else e.Cancel = True End If that should sort you out :)
  20. another simple example is this : Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim sw As StreamWriter = New StreamWriter(New FileStream("C:\test.ini", FileMode.Create)) sw.WriteLine(TextBox1.Text) sw.Close() End Sub
  21. you can either put this at the very top of your code page : Imports System.IO or you can do it like this : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim writer As New System.IO.StreamWriter("C:\test.txt") writer.Write("test") '/// write some text to save in our test.txt writer.Flush() '/// empty the writer. writer.Close() '/// close it down End Sub
  22. Dim frm As New Form2 frm.Show()
  23. dont you think StreamReader / StreamWriter are just 1 of the best things since sliced bread:p it makes all the old vb stuff like #FreeFile look even worse than it was:-\
  24. are you adding the items from a database? or clicking something? how about this idea : Dim strDate As String = "15/06/2003 10:17:56 AM" strDate = strDate.Split(Chr(32))(0) MsgBox(strDate) splitting the date from the rest of the time info. Dim strExp_Date_e As String = Exp_Date_e strExp_Date_e = strExp_Date_e.Split(Chr(32))(0)'/// chr(32) being the space " " Me.lbExp.DataSource = Me.dsExp.Exp Me.lbExp.DisplayMember = strExp_Date_e not sure if this helps.
  25. how exactly do you want your date / time to show? like this: 15-jun-2003 or date and time: 15-jun-2003 11:01:59 or like this 15/06/2003?
×
×
  • Create New...