Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
N

Nick Otten

@Nick Otten
About
Posts
38
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Document Searching
    N Nick Otten

    Hey, Sorry for the double awsner but i ran into this today

    Dim filenames = My.Computer.FileSystem.FindInFiles("C:\", "text you want to find", True, FileIO.SearchOption.SearchAllSubDirectories)

    arguments: 1. root folder, 2. searched text, 3. ignore capital, 4. seachoption. returntype: a array of file locations (string)

    Visual Basic database csharp sql-server sysadmin

  • data connectivity
    N Nick Otten

    Do you have any error message? it can be a million things why it aint working...

    Visual Basic database

  • Document Searching
    N Nick Otten

    So basically what you now have is a database with the cataloged content of all the items? Then i think the best way to go is to indeed use that database. If its a oledb you should be able to access it trough code. if it gives errors check if the permissions of the database allow a external user to read from it. And that there isnt a firewall blocking your path.

    Visual Basic database csharp sql-server sysadmin

  • Document Searching
    N Nick Otten

    You mean content from inside the document? like a word or sentence?

    Visual Basic database csharp sql-server sysadmin

  • Document Searching
    N Nick Otten

    Hello, I'm not completely sure to what you mean, but if your looking for a way to search for items in a directory (both network drive or local drive) you can use the following code:

    Dim filenames = My.Computer.FileSystem.GetFiles("C:", FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
    For Each filename As String In filenames
    messagebox.show(filename)
    Next

    'NOTE if your system gives errors add the following line on top of your class: Imports System.IO

    this example will look for .txt files on your c drive and display each of there file paths in a messagebox. since this function uses the windows search function it will work faster if you got your drives indexed. also narrowing down your search path will speed things up. for querying things from a SQL database you can just push a query text to the server while declaring it as a "SqlCommand" (dont forget to add Imports System.Data.SqlClient on top of your code). here[^] is a tutorial. its for ado.net but it works the same in a vb.net desktop application.

    Visual Basic database csharp sql-server sysadmin

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    It seems your making a mistake in providing the arguemnts for your max scroll.

    Quote:

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load scrollhandler = New MyListener(FlowLayoutPanel1) maxscroll = CalcMaxScroll(FlowLayoutPanel1.Size.Height, FlowLayoutPanel1.Size.Width, 114, 1075, 19) '19 number of tweets '114 height of tweettimelinecontrol '1075 width of flowlayoutpanel1 'last number tells the number of items. (read that from a global var) End Sub

    You say that the with of your flowlayoutpanel is 1075. yet you apply it to the formula as the with of your tweettimelinecontrol. quoting you from a previous post:

    Quote:

    Oh that kinda worked... but how am I ganna calculate the value in a control like this one: When its normal screen size: http://foto.pk/images/minx.png\[^\]

    you can see in the screenshot that you got 2 of those controls next to eachoter so it can never be the total size of your flowlayoutpanel. please check the with property of your Tweettimelinecontrol and change the value. while your at it also change the 19 with a flowlayoutpanel.items.count to make sure it are 19.

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    hmm oke i admid my code was a bit of mess. i cleared it out a bit and made a example program so you can see how it works. Please follow the below steps. 1. start a new form project 2. Add is Listbox. set the name to txtscroll and the size to 254; 381 3. Add a button, call this one btnadd 4. copy paste the following code into the project (under the form you just made)

    Imports System.Runtime.InteropServices

    Public Class Form1

    #Region "declarations"
    Dim WithEvents scrollhandler As MyListener 'class that will watch windows to see if your scrolling
    Private scrolled As Boolean = False 'boolean you can use to flip if a message box was displayed or not...(so it wont loop the messagebox.show)
    Private maxscroll As Int64 'int used to store the max value of the scrollbar
    Private index As Int32 = 0 'used for random loops to fill the txtscroll
    Private Const SB_HORZ As Integer = &H0
    Private Const SB_VERT As Integer = &H1
    #End Region

    #Region "dll calls"
    'dll used to get the scrollbar value NOTE: if the scrollbar is not visible or you go higher then your max it will crash!
    _
    Public Shared Function GetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer) As Integer
    End Function

    'dll used to set the scrollbar value NOTE: if the scrollbar is not visible or you go higher then your max it will crash!
     \_
    Private Shared Function SetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer, ByVal nPos As Integer, ByVal bRedraw As Boolean) As Integer
    End Function
    

    #End Region

    Public Property HScrollPos() As Integer 'property to set or get the horisontal scrollbar value
        Get
            Return GetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_HORZ) 'change txtscroll to the control you use. dont forget the .handle
        End Get
        Set(ByVal value As Integer)
            SetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_HORZ, value, True) 'change txtscroll to the control you use. dont forget the .handle
        End Set
    End Property
    
    
    Public Property VScrollPos() As Integer 'Property to set or get the Vertical scrollbar value
        Get
            Return GetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_VERT) 'change txtscroll to the control you use. dont forget the .handle
        End Get
        Set(ByVal value As Integer)
            SetScrollPos(DirectCast(txtscroll.Handle, IntPtr
    
    Visual Basic algorithms tutorial question

  • Helo Guys i need your help Pls
    N Nick Otten

    Quote:

    Am in the middle of developing a window app when i got stuck

    could you be a bit more specific? perhaps show a bit of code to where you get stuck or witch error you hang on.

    Visual Basic help tools

  • Runtime error debugging
    N Nick Otten

    Hello, Try this[] one Nick

    Visual Basic question mcp help

  • List out all menus in vb6 application
    N Nick Otten

    I'm a little confused to where you refer to drop down controls and drop down item. but the item once can be done pretty easily by code

    dropdownbox.items.add("object, a string as name for example")

    with a loop and some if/else statements you should be able to filter what you add by the users permissions.

    Visual Basic question help

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    Hey, Sorry for my late response. I unfortunately fell ill. to get back to your question: No, you call that function every time after the amount of items in your flowlayoutpanel changes.

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    Private Function CalculateMaxScrollValue(ByVal totalitems As Int64, ByVal controlhight As Int32, ByVal controlwith As Int32)
    'NOTE: 482 and 114 is the size property of your msgctrl.vb
    Return totalitems - (Math.Floor(controlwith / 482) * Math.Floor(controlhight / 114))
    End Function

    Add that function to your code to find the max scroll value. Use that in combination with the code i send you in the previous posts in this topic. replace the txtscroll with the flowlayoutpanel1 and it should work (cant test it here). as a side note: you might want to fine tune the if/else of mine a little to a "<" instead of "=". giving a exact value to a 'analog' control gives it a small change to trigger. also it seems like the program is single threaded. i don't know how long it takes to load those messages but your interface will hang (not responding ect) till the load is complete. looking into threading might be interesting.

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    How do you fill the listbox? with a loop or a data binding? EDIT: oke something just shot to my mind. the items you add to your listbox are controls right? i forgot the object name but i've seen the code of those. this means they have a fixed sized right? you could calculate how much fit into your listbox if you read out the length and hight of it. lets say for example your listbox is 300 pixels wide and 400 pixels high. your controls are 100 wide and 50 high. this would mean you can fit 3 rows of each 8 items = 24 items without scroll bar. so in a 'math' way:

    [ammount of items] - (math.floor([with_listbox]/[with_control])+math.floor([hight_listbox]/[hight_control])) = maximum scroll value

    ------------------- Ah oke, yea now its making sense ;) and i already figured it was for Trocket (read the thread about it) when i was helping you with a previous question.

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    Did you recalculate the max value of your scrollbar? if your listbox is of a differed size then mine (witch it probably is) you have to recalculate it. just run the program. dont scroll and see how many items fit into the listbox (for me that where 18). you want to do the index - [the number you found]. after that it should work.

    maxscroll = index - 18 'calculate max value. everytime you add a item you have to do this again. to calculate this its a bit of a trail and error thing depending on your control

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    hmm, oke im not really sure why you want to show that messagebox. but I thrown in some more trail and error and i came up with the code below. Note that I ran a little low on time so its a bit of a mess...i recommend throwing in a breakpoint to figure out exactly how the code works before putting it into your project. to test it again make a form (called form1) and add a listbox (txtscroll) in it. then copy paste the code into your form.

    Imports System.Runtime.InteropServices

    Public Class Form1
    Dim WithEvents scrollhandler As MyListener 'class that will watch windows to see if your scrolling
    Private scrolled As Boolean = False 'boolean you can use to flip if a message box was displayed or not...(so it wont loop the messagebox.show)
    Private maxscroll As Int64 'int used to store the max value of the scrollbar
    'dll used to get the scrollbar value NOTE: if the scrollbar is not visible or you go higher then your max it will crash!
    _
    Public Shared Function GetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer) As Integer
    End Function

    'dll used to set the scrollbar value NOTE: if the scrollbar is not visible or you go higher then your max it will crash!
    \_
    Private Shared Function SetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer, ByVal nPos As Integer, ByVal bRedraw As Boolean) As Integer
    End Function
    
    Private Const SB\_HORZ As Integer = &H0
    Private Const SB\_VERT As Integer = &H1
    
    
    Public Property HScrollPos() As Integer 'property to set or get the horisontal scrollbar value
        Get
            Return GetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_HORZ) 'change txtscroll to the control you use. dont forget the .handle
        End Get
        Set(ByVal value As Integer)
            SetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_HORZ, value, True) 'change txtscroll to the control you use. dont forget the .handle
        End Set
    End Property
    
    
    Public Property VScrollPos() As Integer 'Property to set or get the Vertical scrollbar value
        Get
            Return GetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_VERT) 'change txtscroll to the control you use. dont forget the .handle
        End Get
        Set(ByVal value As Integer)
            SetScrollPos(DirectCast(txtscroll.Handle, IntPtr), SB\_VERT, value, True) 'change txtscroll to the control you use. dont forget the .handle
        End Set
    
    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    1-0 for you ;)

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    oeh quite nice! might actually try that in the future. but isn't that C#?

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    Oke started a little project to test a bit around and i think you might find this interesting. i used a form called form1. and placed a listbox on it i called txtscroll. I suggest you make a same sort of window and paste the following code in to see how it works:

    Public Class Form1

    Dim WithEvents scrollhandler As MyListener 'class that will watch windows to see if your scrolling
    Private scrolled As Boolean = False 'boolean you can use to flip if a message box was displayed or not...(so it wont loop the messagebox.show)
    
    
    Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'some random loop i used to ditch some data in my listbox for testing
        Dim index As Int32 = 0
        Do While index < 100
            txtscroll.Items.Add(index.ToString())
            index += 1
        Loop
    
        'attach your scrollwatcher to your control. in my case i have a listbox called "txtscroll")
        scrollhandler = New MyListener(txtscroll)
    
    End Sub
    
    Private Sub scrollhandler\_MyScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles scrollhandler.MyScroll
        'place your if/else statement here, its smart to use the scrolled boolean to flip true/false so the messagebox doesnt go on a loop
    End Sub
    
    Private Sub txtscroll\_MouseWheelScroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtscroll.MouseWheel
        scrollhandler\_MyScroll(e, e) 'needed to catch the scrollwheel event.
    End Sub
    
    
    Private Class MyListener
        Inherits NativeWindow
    
        Public Event MyScroll(ByVal sender As Object, ByVal e As EventArgs)
        Const WM\_MOUSEACTIVATE = &H21
        Const WM\_MOUSEMOVE = &H200
        Private control As Control
    
        Public Sub New(ByVal control As Control)
            AssignHandle(control.Handle) 'docks handler to given control
        End Sub
    
        Protected Overrides Sub WndProc(ByRef Messageevent As Message)
            Const WM\_HSCROLL = &H114
            Const WM\_VSCROLL = &H115
            If Messageevent.Msg = WM\_HSCROLL Or Messageevent.Msg = WM\_VSCROLL Then 'looks if the horisontal or verticle scrollbar is moving
                'one of the scrollbars is moving, throw event
                RaiseEvent MyScroll(control, New EventArgs)
            End If
            MyBase.WndProc(Messageevent)
        End Sub
    
        Protected Overrides Sub Finalize()
            'not used in example but drops the
    
    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    Perhaps its not as MS once intended it. or perhaps it is...but the scrolling and value changed are two differed events. if you press one of the scrolls arrows the program will make it scroll in that direction once. and then change the value. but when you drag the bar you scroll every time you move a little...but the value is only changed upon the key release. a easy thing to do is to declare a private boolean (outside the event). and switch it true/false so the message box only displays once.

    Private ScrollingMessage as Boolean = true 'I know not the right place to declare it... put it with your other declarations

    'put this below into your event
    If e.NewValue = e.OldValue and ScrollingMessage Then
    MsgBox("hi")
    ScrollingMessage = false
    elseif e.NewValue <> e.OldValue then
    scrollingmessage = true
    End If

    Visual Basic algorithms tutorial question

  • Event on Scrolling to the end in flowlayoutpanel
    N Nick Otten

    Hey, there is a scroll event for controls. see this[^] for info and how to get/use it. Nick

    Visual Basic algorithms tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups