Professional Documents
Culture Documents
--------------------------------------------------------------------------------
flexgridcolumncolor msflexgrid1, 2, vbred
flexgridrowcolor msflexgrid1, 3, vbblue
--------------------------------------------------------------------------------
vb:
--------------------------------------------------------------------------------
public sub flexgridcolumncolor(flexgrid as msflexgrid, byval lcolumn as long,
byval lcolor as long)
dim lprevcol as long, lprevcolsel as long
dim lprevrow as long, lprevrowsel as long
dim lprevfillstyle as long
with flexgrid
with flexgrid
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
vb:
--------------------------------------------------------------------------------
public function fg_autosizecols(mygrid as mshflexgrid, _
optional byval lfirstcol as long = -1, _
optional byval llastcol as long = -1, _
optional bcheckfont as boolean = false)
if bcheckfont then
' save the forms font settings
bfontbold = me.fontbold
sfontname = me.fontname
dfontsize = me.fontsize
end if
with mygrid
.redraw = false
if bcheckfont then
lcurrow = .row
lcurcol = .col
end if
if bcheckfont then
.row = lcurrow
.col = lcurcol
end if
.redraw = true
end with
if bcheckfont then
' restore the forms font settings
me.fontbold = bfontbold
me.fontname = sfontname
me.fontsize = dfontsize
end if
end function
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
vb:
--------------------------------------------------------------------------------
'dieser source stammt von http://www.activevb.de
'und kann frei verwendet werden. f�r eventuelle sch�den
'wird nicht gehaftet.
'um fehler oder fragen zu kl�ren, nutzen sie bitte unser forum.
'ansonsten viel spa� und erfolg mit diesem source!
option explicit
for zahl = 1 to 9
.additem "dirk lietzow" & vbtab & "dirk@activevb.de" & _
vbtab & "www.activevb.de" & vbtab & zahl & vbtab & _
"alle f�r einen, einer f�r alle ..."
next zahl
' formatierungsbeispiele
.col = 2
.row = 2
.cellfontname = "arial"
.cellfontsize = 11
.col = 2
.row = 3
.cellfontname = "arial"
.cellfontsize = 12
.col = 2
.row = 4
.cellfontname = "arial"
.cellfontsize = 14
.cellfontbold = true
.rowheight(.row) = 500
.col = 2
.row = 6
.cellbackcolor = &h8000000f
.col = 2
.row = 8
.cellfontname = "courier new"
.cellfontsize = 12
.cellfontbold = true
.cellforecolor = vbwhite
.cellbackcolor = &hc00000
.rowheight(.row) = 500
end with
end sub
gref = false
if many > 0 then
' set the number of columns to be printed
' all columns > many get a colwidth = 0
if grid.cols > many then
gbeg = grid.cols - many
redim copycw(gbeg)
grid.redraw = false
for x = many to grid.cols - 1
copycw(x - many) = grid.colwidth(x)
grid.colwidth(x) = 0
next x
gref = true
end if
end if
with trange
.hdc = printer.hdc
'reset
lreturn = sendmessage(grid.hwnd, vp_formatrange, 0, 0)
end if
if gref then
' reset all columns to their original width
for x = many to grid.cols - 1
grid.colwidth(x) = copycw(x - many)
next x
grid.redraw = true
end if
end sub
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
flexspread class
--------------------------------------------------------------------------------
i created a class to extend the functionality of the msflexgrid with excel like
functions.
the class supports cell editing, but you can also add formula's and expressions in
the cell.
like in excel if the text starts with a "=" then the rest of the text is parsed.
vb:
--------------------------------------------------------------------------------
cflexspread.textformula(4, 3) = "=sum([1,1]:[3,3])"
cflexspread.textformula(4, 3) = "=avg([1,1]:[3,3])"
--------------------------------------------------------------------------------
for all other mathematical functions i used the eval method of the scriptcontrol
which can be combined with cell references.
vb:
--------------------------------------------------------------------------------
cflexspread.textformula(4, 3) = "=[1,1] * sin([3,3]))"
--------------------------------------------------------------------------------
vb:
--------------------------------------------------------------------------------
private sub cflexspread_afteredit(row as long, col as long)
debug.print "afteredit", row, col
end sub
--------------------------------------------------------------------------------
last edited by flyguy : 20 jan 2004 at 11:32 am.
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
another sample using a class to save / load the settings of the msflexgrid to /
from a ini style file.
it can save / load the general flexgrid settings, the general layout, the cell
data and the layout of the cells.
vb:
--------------------------------------------------------------------------------
option explicit
end sub
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
vb:
--------------------------------------------------------------------------------
'---------------------------------------------------------------------------------
------
' module : form1
' datetime : 11-7-2004 00:28
' author : flyguy
' purpose : sample using flexgrid as month calendar
'---------------------------------------------------------------------------------
------
option explicit
'---------------------------------------------------------------------------------
------
' procedure : msflexgrid1_dblclick
' datetime : 10-7-2004 23:55
' author : flyguy
' purpose : to enter some data in the clicked cell
'---------------------------------------------------------------------------------
------
'
private sub msflexgrid1_dblclick()
dim lrow as long
dim lcol as long
dim stext as string
with msflexgrid1
lrow = .mouserow
lcol = .mousecol
if lrow / 2 = lrow \ 2 then lrow = lrow + 1
stext = inputbox(.textmatrix(lrow - 1, lcol), , .textmatrix(lrow, lcol))
if strptr(stext) <> 0 then .textmatrix(lrow, lcol) = stext
end with
end sub
private sub msflexgrid1_mousedown(button as integer, shift as integer, x as
single, y as single)
setcellfocus
end sub
'---------------------------------------------------------------------------------
------
' procedure : drawgrid
' datetime : 11-7-2004 00:23
' author : flyguy
' purpose : draw the calendar for the given month
'---------------------------------------------------------------------------------
------
'
private sub drawgrid(byval thedate as long)
dim lfirstdate as long
dim llastdate as long
dim lfirstcol as long
dim lcol as long, lrow as long, lrows as long
dim ldate as long
with msflexgrid1
' no borders etc to autosize nicely
.borderstyle = flexbordernone
.appearance = flexflat
.scrollbars = flexscrollbarnone
' no highlighting
.highlight = flexhighlightnever
.focusrect = flexfocuslight
lrow = 0
lcol = lfirstcol - 1
for ldate = lfirstdate to llastdate
' column and row counters
lcol = lcol + 1
if lcol > 6 then
lrow = lrow + 2
lcol = 0
end if
sizegrid
.redraw = true
end with
end sub
'---------------------------------------------------------------------------------
------
' procedure : sizegrid
' datetime : 11-7-2004 00:23
' author : flyguy
' purpose : resize the cells when the grid is resized
'---------------------------------------------------------------------------------
------
'
private sub sizegrid()
dim lrowheight as long
dim lrow as long
with msflexgrid1
.redraw = false
.redraw = true
end with
end sub
'---------------------------------------------------------------------------------
------
' procedure : setcellfocus
' datetime : 10-7-2004 23:56
' author : flyguy
' purpose : make sure to set the focus to the data part
'---------------------------------------------------------------------------------
------
'
private sub setcellfocus()
dim lrow as long
dim lcol as long
with msflexgrid1
lrow = .mouserow
lcol = .mousecol
if lrow >= 0 and lcol >= 0 then
if lrow / 2 = lrow \ 2 then lrow = lrow + 1
.row = lrow
.col = lcol
end if
end with
end sub
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
using the fillstyle property you can change a range of cells with a single
command.
but you always have to take care about the current selected row, col, rowsel and
colsel properties.
that's why i wrote a generic function which is capable of changing most of the
cell properties with a single command.
vb:
--------------------------------------------------------------------------------
option explicit
with fg
.redraw = false
.redraw = true
end with
end sub
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
quote:
originally posted by flyguy
the msflexgrid does have some capabilities for sorting.
it works great if you want to sort 1 column.
if you want to sort multiple columns the flexgrid always sorts them from left to
right and all in the same order (ascending/descending).
in the previous sort sample i used a stable sorting mechanisme, which means you
sort the data in multiple steps while trying to preserve the orginal data order
for other columns.
somehow it isn't that stable at all and there are some problems when mixing
ascending and descending sorting.
in the next sample i used a different technique which is not stable, but does the
multi column sorting in a single step.
vb:
--------------------------------------------------------------------------------
'---------------------------------------------------------------------------------
------
' module : form1
' datetime : 27-12-2004
' author : flyguy
' purpose : demo for sorting multiple columns, data showed in a msflexgrid
'---------------------------------------------------------------------------------
------
option explicit
private sub form_load()
dim lrow as long, lcol as long
ccolumn.add 0
corder.add 1 ' sort ascending
ccolumn.add 1
corder.add -1 ' sort descending
ccolumn.add 2
corder.add 1 ' sort ascending
end sub
--------------------------------------------------------------------------------
in a module:
vb:
--------------------------------------------------------------------------------
'---------------------------------------------------------------------------------
------
' module : modshellsort
' datetime : 27-12-2004
' author : flyguy
'---------------------------------------------------------------------------------
------
option explicit
'---------------------------------------------------------------------------------
------
' procedure : shellsortmulticolumn
' datetime : 27-12-2004
' author : flyguy
' purpose : sort a 2d string array on multiple columns
'---------------------------------------------------------------------------------
------
public sub shellsortmulticolumn(sarray() as string, ccolumns as collection, _
corder as collection)
lnofcolumns = ccolumns.count
redim acolumns(lnofcolumns)
redim aorder(lnofcolumns)
for lloop1 = 1 to lnofcolumns
acolumns(lloop1) = ccolumns(lloop1)
aorder(lloop1) = corder(lloop1)
next lloop1
lubound = ubound(sarray)
llbound = lbound(sarray)
lubound2 = ubound(sarray, 2)
llbound2 = lbound(sarray, 2)
end sub
'---------------------------------------------------------------------------------
------
' procedure : swaplines
' datetime : 27-12-2004
' author : flyguy
' purpose : swap a row of data in a 2d array
'---------------------------------------------------------------------------------
------
private sub swaplines(byref sarray() as string, lindex1 as long, _
lindex2 as long, llbound as long, lubound as long)
'---------------------------------------------------------------------------------
------
' procedure : comparevalues
' datetime : 27-12-2004
' author : flyguy
' purpose : compare column values for multicolumn sorting
'---------------------------------------------------------------------------------
------
private function comparevalues(byref sarray() as string, lindex1 as long, _
lindex2 as long, lnofcolumns as long, acolumns() as long, aorder() as long)
dim i as long
dim lcol as long
dim svalue1 as string, svalue2 as string
for i = 1 to lnofcolumns
lcol = acolumns(i)
if aorder(i) = 1 then
svalue1 = sarray(lindex1, lcol)
svalue2 = sarray(lindex2, lcol)
else
svalue1 = sarray(lindex2, lcol)
svalue2 = sarray(lindex1, lcol)
end if
next i
end function
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
vb:
--------------------------------------------------------------------------------
'---------------------------------------------------------------------------------
------
' procedure : comparevalues
' datetime : 27-12-2004
' author : flyguy
' purpose : compare column values for multicolumn sorting
' revision : 15-02-2005, take in account numeric and date values
'---------------------------------------------------------------------------------
------
private function comparevalues(byref sarray() as string, lindex1 as long, _
lindex2 as long, lnofcolumns as long, acolumns() as long, aorder() as long)
dim i as long
dim lcol as long
dim svalue1 as string, svalue2 as string
dim dvalue1 as double, dvalue2 as double
dim bnumeric as boolean
for i = 1 to lnofcolumns
lcol = acolumns(i)
if aorder(i) = 1 then
svalue1 = sarray(lindex1, lcol)
svalue2 = sarray(lindex2, lcol)
else
svalue1 = sarray(lindex2, lcol)
svalue2 = sarray(lindex1, lcol)
end if
if bnumeric then
if dvalue1 < dvalue2 then
exit for
elseif dvalue1 > dvalue2 then
comparevalues = true
exit for
end if
else
if svalue1 < svalue2 then
exit for
elseif svalue1 > svalue2 then
comparevalues = true
exit for
end if
end if
next i
end function
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
private declare function getsyscolor lib "user32" (byval nindex as long) as long
'---------------------------
' procedure : htmlcolor
' datetime : 30-1-2004
' author : componentone
' purpose : converts a vb color into html color code
'---------------------------
private function htmlcolor(byval lcolor as long) as string
dim stemp as string
'---------------------------
' procedure : htmltext
' datetime : 30-1-2004
' author : componentone
' purpose : converts a vb string into an html string
'---------------------------
private function htmltext(byval sline as string) as string
if len(sline) = 0 then
htmltext = " "
else
htmltext = replace$(sline, "&", "&")
htmltext = replace$(htmltext, "<", "<")
htmltext = replace$(htmltext, ">", ">")
end if
end function
'---------------------------
' procedure : flexgridtohtml
' datetime : 7-4-2005
' author : componentone, adapted by flyguy to be used with msflexgrid
' purpose : exporting msflexgrid to html
'---------------------------
public function flexgridtohtml(fg as msflexgrid) as string
dim sdata as string, sline as string
dim dtblwidth as double
dim i as long, lrow as long, lcol as long
dim sspan as string
dim lrow1 as long, lrow2 as long, lcol1 as long, lcol2 as long
dim dwidth as double
dim stext as string, stemp as string
dim sbackground as string, lcolor as long
dim sfont as string, sborder as string, sfontfx as string
dim salign as string, scell as string
dim bprocesscell as boolean
with fg
.redraw = false
sline = ""
.col = lcol
.row = lrow
bprocesscell = true
if bprocesscell then
if lcol2 > lcol then sspan = " colspan=" & (lcol2 - lcol + 1)
if lrow2 > lrow then sspan = sspan & " rowspan=" & (lrow2 - lrow +
1)
next lcol
.redraw = true
end with
' table end
sdata = sdata & "</table></font>"
'---------------------------
' procedure : getmergedcols
' datetime : 7-4-2005
' author : flyguy
'---------------------------
private sub getmergedcols(fg as msflexgrid, byval row as long, _
byval col as long, byref lstart as long, byref lend as long)
dim lcol as long
dim lcnt as long
lstart = col
lend = col
with fg
if row < .fixedrows then
for lcol = col - 1 to 0 step -1
if .colwidth(lcol) <> 0 then
if .textmatrix(row, lcol) = .textmatrix(row, col) then
lcnt = lcnt + 1
else
exit for
end if
end if
next lcol
if lcnt > 0 then lstart = col - lcnt
lcnt = 0
for lcol = col + 1 to .cols - 1
if .colwidth(lcol) <> 0 then
if .textmatrix(row, lcol) = .textmatrix(row, col) then
lcnt = lcnt + 1
else
exit for
end if
end if
next lcol
if lcnt > 0 then lend = col + lcnt
end if
end with
end sub
'--------------------------
' procedure : getmergedrows
' datetime : 7-4-2005
' author : flyguy
'--------------------------
private sub getmergedrows(fg as msflexgrid, byval row as long, _
byval col as long, byref lstart as long, byref lend as long)
dim lrow as long
dim lcnt as long
lstart = row
lend = row
with fg
if col < .fixedcols then
for lrow = row - 1 to 0 step -1
if .rowheight(lrow) <> 0 then
if .textmatrix(lrow, col) = .textmatrix(row, col) then
lcnt = lcnt + 1
else
exit for
end if
end if
next lrow
if lcnt > 0 then lstart = row - lcnt
end with
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
last edited by flyguy : 7 apr 2005 at 07:41 am.
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
--------------------------------------------------------------------------------
snippet from ms knowledge base how to put html data on the clipboard, so you can
paste in for example word:
vb:
--------------------------------------------------------------------------------
'---------------------------------------------------------------------------------
------
' module : modclipboardhtml
' datetime : 2-4-2004
' author : microsoft
' purpose : howto: add html code to the clipboard by using visual basic
' revision :
'---------------------------------------------------------------------------------
------
option explicit
end function
'add the starting and ending tags for the html fragment
scontextstart = scontextstart & "<!--startfragment -->"
scontextend = "<!--endfragment -->" & scontextend
'build the html given the description, the fragment and the context.
'and, replace the offset place holders in the description with values
'for the offsets of starthmtl, endhtml, startfragment and endfragment.
sdata = m_sdescription & scontextstart & shtmlfragment & scontextend
sdata = replace(sdata, "aaaaaaaaaa", _
format(len(m_sdescription), "0000000000"))
sdata = replace(sdata, "bbbbbbbbbb", format(len(sdata), "0000000000"))
sdata = replace(sdata, "cccccccccc", format(len(m_sdescription & _
scontextstart), "0000000000"))
sdata = replace(sdata, "dddddddddd", format(len(m_sdescription & _
scontextstart & shtmlfragment), "0000000000"))
if cbool(hmemhandle) then
lpdata = globallock(hmemhandle)
if lpdata <> 0 then
end if
end if
call closeclipboard
end if
end sub
if cbool(openclipboard(0)) then
globalunlock hmemhandle
if cbool(hmemhandle) then
lpdata = globallock(hmemhandle)
if lpdata <> 0 then
nclipsize = lstrlen(lpdata)
sdata = string(nclipsize + 10, 0)
call copymemory(byval sdata, byval lpdata, nclipsize)
end if
nindx = instr(sdata, "endfragment:")
if nindx then
nendfrag = clng(mid(sdata, nindx + len("endfragment:"), 10))
end if
end if
end if
call closeclipboard
end if
end function
--------------------------------------------------------------------------------
flyguy
view public profile
send a private message to flyguy
find all posts by flyguy
add flyguy to your buddy list
-------------------------------------------
dim subtotdebit as single
dim subtotcredit as single
dim totalamount a single
for row = 1 to grid.rows - 1
if isnumeric(grid.cell(flexcptext, row, 3)) then subtotdebit =
round(subtotdebit, 2) + round(csng(grid.cell(flexcptext, row, 3)), 2)
if isnumeric(grid.cell(flexcptext, row, 4)) then subtotcredit =
round(subtotcredit, 2) + round(csng(grid.cell(flexcptext, row, 4)), 2)
next row
subtotdebit =123.45
subtotcredit =123.45
totalamount =123.45
however, the debugger jumps to do_b. how can i solve this, since the
debugger doesn't show that it performs good.
oscar
for i = 0 to msflexgrid1.cols
if not (msflexgrid1.textmatrix(i, 2)) = "" then
msflexgrid1.textmatrix(i, 5) = msflexgrid1.textmatrix(i, 2) / 5
end if
next
for i = 0 to msflexgrid1.cols
if isnumeric (msflexgrid1.textmatrix(i, 2)) then
msflexgrid1.textmatrix(i, 5) = cstr(cdbl(msflexgrid1.textmatrix(i, 2)) /
5)
end if
next
for i = 1 to val
if isnumeric(msflexgrid1.textmatrix(i, 2)) then
if not msflexgrid1.textmatrix(i, 2) = 0 then
msflexgrid1.textmatrix(i, 5) = cstr(msflexgrid1.textmatrix(i, 2) / 5)
else
msgbox (" you cant enter a zero value for volume! ")
exit sub
end if
end if
next
projects
here are summaries of some of the projects we've done. we've been developing
software under the name successful software since 1981. in that time we've
developed applications for a number of different companies and in a variety of
industries. what you see described here by no means includes every project we've
ever worked on. if you are seeking someone with experience not described here,
feel free to call or email us if you would like to talk about it further. (if it
turns out that we don't have the experience you're after, we may be able to refer
you to someone who does.)
some projects involved creating a new application "from scratch" to handle sales
entry / order entry. some of these applications were designed to "stand alone",
without interfacing to other accounting applications. other applications were done
in a way that integrated with an existing accounting application.
some projects involved modifying the source code for an existing "off-the-shelf"
integrated accounting application to tailor the application to the needs of the
company. this included modifications such as collecting additional data and
carrying it through various update processes, and adding new functionality by
modifying existing screens or adding new ones.
other projects involved exporting sales transaction data on a regular basis from
an existing accounting application, such as peachtree accounting
(www.peachtree.com) or others, to a new custom database. this was to provide
special sales analysis or salesperson summary reporting not available in the
accounting application.
healthcare
developed a system for processing medical claims. the system had screens for
entering medical claims, pre-authorizing medical services to be rendered,
maintaining data on facilities, physicians, health plans, plan members, diagnosis
and procedure codes, and procedure fee schedules. it included a seamlessly
integrated table-driven reporting system (using seagate crystal reports automation
objects). the entire system, including reporting, was designed in a 3-tier
architecture for maximum scalability. data that was analyzed frequently for
decision support purposes was automatically loaded on a daily basis into a
separate datamart database (using star-schema table designs). this allowed large
amounts of data to be queried in seconds.
developed a compensation system for physicians along with another programmer as
part of a four-man team that also included a tester and a report developer. the
application involved mechanisms for pooling, allocating, weighting, and adjusting
charge and payment transactions to calculate compensation amounts. transaction
were pooled and accumulated by various criteria: procedure (cpt) codes, modifiers,
sites, sort keys, payers, etc. the application also handled capitated payments and
fee-for-service transactions.
food production
created an application for a bagel bakery chain to assist with calculating
economic order quantities of various types of dough. the application tracked a
history of usage which it then took into consideration along with pending orders
in suggesting future order quantities.
price quotes
created an application to assist a supplier with locating the best prices
available from a large number of vendors to satisfy a given customer order. the
application automatically faxed requests for price quotes to vendors through
winfax pro software (made by symantec - www.symantec.com) to facilitate the
process of filling customer orders.
insurance
made various enhancements to an application designed for an insurance carrier in
the los angeles area. improvements were made in the areas of calculating agent
commissions and chargebacks, "re-insurance" calculations and reporting, and
others.
mail order
modified the order entry software of a men's clothing catalog company to check for
"bad risk" orders. this involved checking billing or shipping addresses against a
"bad risk" file provided by an outside vendor. the matching made use of a
"soundex" algorithm. (this is an algorithm that makes it possible to match up
similar-sounding names or streets, and thereby allow for alternate spellings. for
example, "smith", "smyth", and "smythe" could be matched with a soundex
algorithm.) the algorithm had to be coded by hand on this particular assignment.
(in many environments soundex is available as a built-in function.)
budgetary accounting
developed the "encumbrance accounting" portion of an accounting system for
municipalities. (other team members developed other portions of the accounting
system.) this allowed users to enter initial budgeted amounts for each of their
accounts. throughout the year, updates to the general ledger kept track of how
much budgeted money in each account had been "spent" and what was still available.
(this application was eventually purchased by several cities in san diego,
riverside, and san bernardino counties. we later did additional custom programming
on this software for a city in the riverside area to improve the accounts payable
reporting and to make other enhancements.)
serial communications
we've done a number of projects involving serial communications. some of these
were: interfacing a bar code reader in a point-of-sale environment. creating
software for capturing and storing digitizer output. (this was a large calcomp
digitizer. it was used with a set of blueprints in construction estimating. the
output contained measurements, computed area, and counts of construction
materials.) communication with a cash register to retrieve the day's transactions
(which it stored internally). communication with an optical mark reader being used
to grade test papers to retrieve its data.
human resources
developed various screens, reports, form letters, and exports of data to
spreadsheet software in a human resource database application. this was to keep up
with ever-changing government regulatory changes related to hcfa, osha, eeo, etc.
in addition, reports and spreadsheet interfaces were developed to assist with the
process of wage rate review, performance reviews, and tracking of employee
licenses and education.
privacy considerations
created interfaces from / to a customized human resource database application to
an application designed for random drug testing compliance. modified the human
resource database to assist with tracking employees participating in
rehabilitation. confidentiality of data was a large consideration in developing
the interface that allowed data to be moved between applications. for example,
identifying information such as employee name or social security number could not
be moved through the interface, nor be attached to testing samples. yet, certain
information updated in the drug testing application had to find its way back to
the correct employee in the human resource application.
4000
09-13-2005 08:17 am
--------------------------------------------------------------------------------
visual basic
code:-----------------------------------------------------------------------------
---
private sub command1_click()
dim i%, j%
with fgrid
doevents
if .rows < 2 then exit sub 'top row is a header
for j = 1 to .rows - 1
for i = 1 to .cols - 1
.row = j
.col = i
if j mod 2 = 0 then
.cellbackcolor = &hdaf3cf 'light green
else
.cellbackcolor = vbwhite
end if
next i
next j
.row = 2
.col = 2
.setfocus
end with
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
case is < 32
case else
with mshflexgrid1
.text = .text & chr(keyascii)
end with
end select
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
visual basic
code:-----------------------------------------------------------------------------
---
option explicit
with fgrid
if .row = 0 then exit sub
icurrow = .row
if .row <> ilastrow then
.row = ilastrow
for j = 1 to .cols - 1
.col = j
if ilastrow mod 2 = 0 then
.cellbackcolor = oddrow_color
else
.cellbackcolor = evenrow_color
end if
next j
else
exit sub
end if
.row = icurrow
for j = 1 to .cols - 1
.col = j
.cellbackcolor = selrow_color
next j
ilastrow = .row
end with
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
visual basic
code:-----------------------------------------------------------------------------
---dim i as long
dim p as long
dim newcell as string
dim xl as excel.application
set xl = createobject("excel.application")
xl.workbooks.open (app.path & "\book1")
doevents
xl.visible = true
for i = 1 to msflexgrid1.rows - 1
for p = 1 to msflexgrid1.cols - 1
msflexgrid1.col = p
msflexgrid1.row = i
newcell = chr(i + 64) & p
xl.worksheets("sheet1").range(newcell).value = msflexgrid1.text
next
next
--------------------------------------------------------------------------------we
are on a roll rhinobull! :d
--------------------------------------------------------------------------------
oh yea, we are!!! :p
here is another one: getting selected values (this is really very quick sample):
visual basic
code:-----------------------------------------------------------------------------
---
private sub command1_click()
'================================
dim i%, j%, intendrow%, iendcol%
dim sbuffer$, arvalues() as string
with fgrid
intendrow = .rowsel
iendcol = .colsel
for i = intstartrow to intendrow
sbuffer = sbuffer & .textmatrix(i, iendcol) & vbnewline
next i
end with
arvalues = split(sbuffer, vbnewline)
for i = 0 to ubound(arvalues)
debug.print arvalues(i)
next i
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
:) :) :)
export to a comma separated file:
visual basic
code:-----------------------------------------------------------------------------
---
private sub command1_click()
'============================
dim i%, j%, strrowtext$
screen.mousepointer = vbhourglass
open app.path & "\test.csv" for output as #1
with fgrid
for i = 1 to .rows - 1
strrowtext = ""
for j = 1 to .cols - 1
strrowtext = strrowtext & .textmatrix(i, j) & "," 'vbtab
next j
print #1, strrowtext
next i
end with
close #1
screen.mousepointer = vbdefault
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
hmm ... between the two of us we have covered pretty much so that will give
whatupdoc a good start i'm sure. :thumb:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
wow so much info need to process it all. btw i rated this as execellent since
theres so much good information!
--------------------------------------------------------------------------------
there are a few things you can use to optimize your flexgrid code.
1) use the fillstyle property and work with a range of cells. try to avoid looping
through all rows and all columns. the code below colours alternate rows (similar
to the code already posted) but executes much faster - especially with a large
number of cells.
2) use the redraw property - set it to false before starting the code and back to
true after the code executes. this ensures the grid is not refreshed until after
the process has completed.
visual basic
code:-----------------------------------------------------------------------------
--- dim i as long
with me.msflexgrid1
.redraw = false
.fillstyle = flexfillrepeat
.redraw = true
end
with------------------------------------------------------------------------------
--
visual basic
code:-----------------------------------------------------------------------------
--- with me.msflexgrid1
.redraw = false
.fillstyle = flexfillrepeat
.fillstyle = flexfillsingle
.row = .fixedrows
.col = .fixedcols
.redraw = true
end
with------------------------------------------------------------------------------
--
msflexgrid1.rowheight(-1) = 400
msflexgrid1.colalignment(-1) = flexalignrightcenter
hi hack,
i find this one interesting. can you please help a vb6 newbie here on how to
include the column headings into the excel file?
quote:
originally posted by hack
visual basic
code:-----------------------------------------------------------------------------
---dim i as long
dim p as long
dim newcell as string
dim xl as excel.application
set xl = createobject("excel.application")
xl.workbooks.open (app.path & "\book1")
doevents
xl.visible = true
for i = 1 to msflexgrid1.rows - 1
for p = 1 to msflexgrid1.cols - 1
msflexgrid1.col = p
msflexgrid1.row = i
newcell = chr(i + 64) & p
xl.worksheets("sheet1").range(newcell).value = msflexgrid1.text
next
next
--------------------------------------------------------------------------------we
are on a roll rhinobull! :d
--------------------------------------------------------------------------------
new procedure added that populates flexgrid from comma delimited file:
visual basic
code:-----------------------------------------------------------------------------
---
private sub command1_click()
'=====================================================
dim i%, j%, strheader$, strline$, aritems() as string
screen.mousepointer = vbhourglass
open app.path & "\test.csv" for input as #1
with fgrid
.clear
.rows = 1
'set headers
line input #1, strheader
aritems = split(strheader, ",")
.cols = ubound(aritems) + 1
for j = 0 to ubound(aritems)
.textmatrix(i, j) = aritems(j)
next j
end sub
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
i've just used the export to excel code (works great) and i've modified it to
include the column and row headings
visual basic
code:-----------------------------------------------------------------------------
---dim q as long
dim p as long
dim newcell as string
dim xl as excel.application
set xl = createobject("excel.application")
xl.workbooks.open ("d:\university\3rd year\final year project\my
results\book1")
doevents
xl.visible = true
for p = 0 to msflexgrid1.rows - 1
for q = 0 to msflexgrid1.cols - 1
msflexgrid1.col = q
msflexgrid1.row = p
newcell = chr(q + 65) & p + 1
xl.worksheets("sheet1").range(newcell).value = msflexgrid1.text
next
next------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------
visual basic
code:-----------------------------------------------------------------------------
---private mlngdragcolumn as long