visual basic quickie

Discussion in 'Software' started by stiched, Feb 25, 2006.

  1. stiched

    stiched Private First Class

    hi, i have done my research but i cant find anything anywhere

    i have a set on numbers set in a record using visual basic, what i need to do if find the highest and lowest number in this "age" field, how would i go about finding the highest or lowest value in any set on data? i cant find a function for it and the only way i can think of is long and complex.

    i need as answer quick so anyone feel free to answer

    thankz
     
  2. Kodo

    Kodo SNATCHSQUATCH

    if this is coming from a recordset then you can return the data using SQL in your query..

    Create "StoredProcedureName"

    AS
    Select MAX ISNULL([age],0) from [table]
    Select MIN ISNULL([age],0) from [table]

    when you execute the command, then do

    set RS= New ADODB.RECORDSET
    SQL="StoredProcedureName"
    RS.OPEN SQL, ConnectionObject, 0,1
    MAXAGE=Recordset(0)
    set rs=rs.nextrecordset
    MINAGE=Recordset(0)


    of course you should always check for EOF.. that should get you what you want.
     
  3. stiched

    stiched Private First Class

    ok.. thanks for the tme and effort there kodo but im a right n00b. i have no idea what SQL is and all that stuff below it. i found a way of doing it anyway.

    while im here,can i ask how i can open exernal programs by opening a .exe .
    for example say i open a .exe and on the form load it opens a shortcut on the desktop to microsoft work. so that word wil then open up.

    is this possible and if so how can it be done?

    thankz
     
  4. Kodo

    Kodo SNATCHSQUATCH

  5. stiched

    stiched Private First Class

    yes thankz Kodo, that was exactly the type of thing that i have been searching for!

    now back to the first question again. for example if i had this array...

    dim spam(1 to 100) as integer

    each part of the array has a random number in it.

    what calculation would i have to preform to find the biggest and the smallest numbers in the array. i would also need to know what part of the array it is located, for example..

    highest number is 3432 located at spam(67)

    or

    smallest number is 5 located at spam(45)

    i hope that this makes things clearer. thanks

    p.s a sharpish response would be appreciated as the assignment i am doing is already late
     
  6. Kodo

    Kodo SNATCHSQUATCH

    try this
    Code:
    Dim ArrMaxTemp As Integer
    Dim ArrMaxIndex As Integer
    Dim ArrMinTemp As Integer
    Dim ArrMinIndex As Integer
    
    
    for i=0 to ubound(arr)
        if ArrMaxTemp<>"" then
            if arr(i)>ArrMaxTemp then
            ArrMaxTemp=Arr(i)
            ArrMaxIndex=i
            end if
        else
            ArrMaxTemp=Arr(i)
            ArrMaxIndex=i
        end if
    
        if ArrMinTemp<>"" then
            if arr(i)<ArrMinTemp then
            ArrMinTemp=Arr(i)
            ArrMinIndex=i
            end if
        else
            ArrMinTemp=Arr(i)
            ArrMinIndex=i
        end if
    next
    
    
    debug.print ArrMaxTemp &":"&arrMaxIndex
    debug.print vbCrLf
    debug.print ArrminTemp &":"&arrminIndex
    
    
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds