51

(3 replies, posted in Script)

Hello prahousefamily

And if instead of giving the basic Windows name of the color (i.e. clBlue), you gave it its hexadecimal value (i.e. "# 008000")?
It's a habit I took in my MVD projects when it comes to manipulating colors

JB


I try change code  "# 008000" It error format can not use in mvd script
and
i try change code $008000 OK Not Error But Not Effect ! 

How To Fix ?

52

(3 replies, posted in Script)

I try edit code and add property in progressbar but note effect
- BackgroundColor
- BarColor

How to Fix ? Or have bug ?


https://i.ibb.co/QP4Zswy/2019-04-04-001.png

progressbar is text character

I try use than  real progressbar for show process
For MVD Community  Happy! Happy!

https://i.ibb.co/2WY4tZh/2019-04-02-003.png

Note Code Keyword !
can change font Or change scale Bar 1:20 To 1:10 Or 1:1

            IF Round(records/(MaxRow-1)*100.00) = 0   Then bar := '□□□□□□□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 5   Then bar := '■□□□□□□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 10  Then bar := '■■□□□□□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 15  Then bar := '■■■□□□□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 20  Then bar := '■■■■□□□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 25  Then bar := '■■■■■□□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 30  Then bar := '■■■■■■□□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 35  Then bar := '■■■■■■■□□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 40  Then bar := '■■■■■■■■□□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 45  Then bar := '■■■■■■■■■□□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 50  Then bar := '■■■■■■■■■■□□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 55  Then bar := '■■■■■■■■■■■□□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 60  Then bar := '■■■■■■■■■■■■□□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 65  Then bar := '■■■■■■■■■■■■■□□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 70  Then bar := '■■■■■■■■■■■■■■□□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 75  Then bar := '■■■■■■■■■■■■■■■□□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 80  Then bar := '■■■■■■■■■■■■■■■■□□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 85  Then bar := '■■■■■■■■■■■■■■■■■□□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 90  Then bar := '■■■■■■■■■■■■■■■■■■□□' ;
            IF Round(records/(MaxRow-1)*100.00) = 95  Then bar := '■■■■■■■■■■■■■■■■■■■□' ;
            IF Round(records/(MaxRow-1)*100.00) = 100 Then bar := '■■■■■■■■■■■■■■■■■■■■' ;

54

(3 replies, posted in Script)

Original Basic Project Example Auto Import Value Multiple Excel (Easy Code!)
http://myvisualdatabase.com/forum/viewtopic.php?id=5163

For MVD Community Happy ! Happy ! New  Add Component Display
- Status Import Process
- Count Down Row Import
- Progress Bar

Screen
https://i.ibb.co/vqrWYqB/Image-014.png
https://i.ibb.co/QXWbjSb/Image-015.png

Open Code

var
  apppath : string;
  pb : Tprogressbar;

procedure Form1_TableGrid2_OnChange (Sender: TObject);
begin
  Form1.TableGrid2.BestFitColumns(bfboth);
end;

procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
var
  t : integer;
  i : integer;
  r : integer;
  c : integer;
  ExcelFile : Variant;
  WorkBook  : Variant;
  WorkSheet : Variant;
  MaxRow : Integer;
  MaxCol : Integer;
  value : String;
  sql_code : string;
  records : integer;
  records_all : integer;
begin
  records_all := 0;
  For t := 0 To Form1.TableGrid1.RowCount - 1 do
  begin
    Form1.Label11.Caption :=  Form1.TableGrid1.Cells[0,t];
    Form1.Label2.Caption := Inttostr(t+1)+'/'+ inttostr(Form1.TableGrid1.RowCount);
    ExcelFile :=  CreateOleObject('Excel.Application');
    WorkBook  :=  ExcelFile.WorkBooks.Open( Form1.TableGrid1.Cells[0,t] );
    WorkSheet :=  WorkBook.WorkSheets.Item['sheet1'];
    MaxRow := WorkSheet.Usedrange.EntireRow.count;
    MaxCol := WorkSheet.Usedrange.EntireColumn.count;

    Form1.Label5.Caption := Formatfloat(',0',Maxrow-1);
    Form1.Label7.Caption := Formatfloat(',0',Maxcol);
    records := 0;
    For r := 2 To MaxRow Do //No Head Column Start At Row 2 Excel
    Begin
      value := '';
      For c := 1 To maxCol Do //Start At Column 1 Excel
      Begin
        value := value +'"'+WorkSheet.Cells[r, c].Value+'",';
      End
      ;
      records := records +1;
      Form1.Label9.caption := Formatfloat(',0',records)+'/'+Formatfloat(',0',Maxrow-1);
      sql_code := 'Insert OR Ignore Into value_excel (long_string) values (''{'+Copy(value,1,Length(value)-1)+'}'');';
      sqlexecute(sql_code);
      pb.position :=  round( (r-1)/(maxRow-1)*100.00 );
      Form1.Label10.Caption := Formatfloat('.00',((r-1)/(maxRow-1)*100.00))+' %';
      records_all := records_all +1;
      application.ProcessMessages;
    End;
    WorkBook.Save;
    WorkBook.Close;
    ExcelFile.Quit;
    sqlexecute(' update file_excel set record = '+IntToStr(records) +' where path = "'+escape_special_characters(Form1.Label11.Caption)+'";');
    Form1.TableGrid1.dbUpdate;
    application.ProcessMessages;
  end;
  showmessage('OK! '+FormatFloat(',0',records_all)+' Records' );
end;

procedure Form1_OnClose (Sender: TObject; Action: string);
begin
  sqlexecute('delete from file_excel;');
end;

procedure Form1_TableGrid1_OnChange (Sender: TObject);
begin
  Form1.TableGrid1.BestFitColumns(bfboth);
end;

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
  s : String;
  sl: Tstringlist;
  i : integer;
begin
  Form1.Label2.Caption := '0/0';
  Form1.Label5.Caption := '0';
  Form1.Label7.Caption := '0';
  Form1.Label9.Caption := '0/0';
  Form1.Label10.Caption := '0 %';


  sqlexecute('delete from file_excel;');
  Form1.TableGrid1.dbUpdate;
  SelectDirectory('Select Folder Excel Files','',s,True,True);
  Form1.Edit1.Text := s;
  sl := Tstringlist.create;
  sl.text := GetFilesList(Form1.Edit1.Text ,'*.xls*',true);
  For i := 0 To sl.count - 1 DO
  sqlexecute('insert into file_excel (path,record) values ("'+
  escape_special_characters(sl[i])+'",0);');
  Form1.TableGrid1.dbUpdate;
  sl.free;
end;

begin
  apppath := ExtractFilePath(Application.ExeName);

  pb := Tprogressbar.Create(Form1);
  pb.parent := Form1.Panel2;
  pb.align := alclient;
  pb.min := 0;
  pb.max := 100;
  pb.barcolor := clRed;
  pb.BackgroundColor := clblack;
  pb.width := form1.Panel2.Width;
  pb.position := 0;

end.

Loop Read Value Multiple Excel File In Folder (MVD Can function for select folder by SelectDirectory(,,,,) )
For MVD Can  modify value to sql insert script to database easy like use time third party database manager import excel function 

Happy ! Happy !
Note ***
Order Cell Table IN MVD start (column(0),row(0))
But
Order Cell Table IN Excel start (row(1),column(1))


https://i.ibb.co/DwV4nHN/2019-03-28-002.png

OpenCode

var
apppath : string;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
i : integer ;
r : integer ;
c : integer ;
ExcelFile : Variant;
WorkBook  : Variant;
WorkSheet : Variant;
MaxRow : Integer;
MaxCol : Integer;
value : String;
sl : Tstringlist ;
sql_code : string;
begin
    sl := Tstringlist.Create ;
    For i:= 0 To Form1.Memo1.lines.count - 1 Do
    Begin
        ExcelFile :=  CreateOleObject('Excel.Application');
        WorkBook  :=  ExcelFile.WorkBooks.Open( Form1.Memo1.Lines[i]) ;
        WorkSheet :=  WorkBook.WorkSheets.Item['sheet1'];
        MaxRow := WorkSheet.Usedrange.EntireRow.count ;
        MaxCol := WorkSheet.Usedrange.EntireColumn.count;
        For r := 2 To MaxRow Do //No Head Column Start At Row 2 Excel
        Begin
            value := '';                       
            For c := 1 To MaxCol Do //Start At Column 1 Excel
            Begin
            value := value +'"'+WorkSheet.Cells[r, c].Value+'",' ;
            End ;
            sql_code := 'Insert OR Ignore Into import_value (long_string) values (''{'+Copy(value,1,Length(value)-1)+'}'');' ;
            Form1.Label1.Caption := sql_code ;
            sl.add(sql_code) ;
        End;
        WorkBook.Save;
        WorkBook.Close;
        ExcelFile.Quit;
    End;
    Application.ProcessMessages;
    Form1.Memo2.Text := sl.text ;
    sl.clear;
    KillTask('EXCEL.EXE');
    Form1.Label1.Caption := IntToStr(Form1.Memo2.Lines.Count)+' Record' ;
    Showmessage( IntToStr(Form1.Memo2.Lines.Count)+' Record');
end;
begin
    apppath := ExtractFilePath(Application.ExeName) ;
    Form1.Memo1.Text := GetFilesList(apppath+'ExcelFile','*.xls*',True);
end.

56

(2 replies, posted in Script)

Reference From 
Get data from excel file
http://delphiexamples.com/others/excelinfo.html
&
Fast way to load Excel spreadsheet [closed]
https://stackoverflow.com/questions/148 … preadsheet





Try Edit Code Fun & Easy For  MVD Community

https://i.ibb.co/yNXWf6T/2019-03-25-002.png

OpenCode

procedure Form1_Button3_OnClick (Sender: TObject; var Cancel: boolean);
var
i_sql : integer ;
begin
    For i_sql := 0 To Strtoint(Form1.Label1.Caption) -1 Do
    Begin
        SQLExecute(Form1.Memo1.Lines[i_sql]) ;
        Form1.Label2.Caption := IntToStr(i_sql+1) ;
        Form1.Label3.Caption := FormatFloat('0.00',(i_sql+1)/StrTOInt((Form1.Label1.Caption))*100)+' %' ;
        Application.ProcessMessages;
    End;
    Application.ProcessMessages;
    Form1.TableGrid1.dbUpdate ;
end;
procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
var
Excel : Variant ;
Sheet : Variant ;
rows, columns : Integer;
MaxRow : Integer;
MaxCol : Integer;
result_string : string;
sql_string : string ;
irows : integer ;
begin
    Excel:=CreateOleObject('Excel.Application');
    //Excel.Visible:= True;
    Excel.Workbooks.Open(Form1.Edit1.Text) ;
    Sheet := Excel.WorkSheets[1] ;
    MaxRow := Sheet.Usedrange.EntireRow.count ;
    MaxCol := sheet.Usedrange.EntireColumn.count;
    //special excel[row,column]
    irows := 0 ;
    For  rows := 2 To  MaxRow Do
    Begin
        For  columns := 1 To Maxcol Do
        Begin
            result_string := result_string + '"'+Excel.ActiveSheet.Cells[rows,columns].Value+'",'
        End;
        sql_string :=
        'INSERT OR IGNORE INTO import_excel(id,date_text,year_text,month_text,day_text) values ('+
        copy(result_string,1, Length(result_string)-1)+');';
        Form1.Memo1.Lines.Add(sql_string) ;
        irows := irows +1 ;
        result_string := '' ;
        sql_string := '' ;
        Form1.Label1.Caption := IntToStr(irows);
    End;
    Application.ProcessMessages;
    Excel.Workbooks.Close;
    KillTask('EXCEL.EXE');
end;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
opendialog : Topendialog ;
begin
    opendialog := Topendialog.Create(Form1) ;
    IF opendialog.execute Then
    Form1.Edit1.Text := opendialog.filename ;
    opendialog.free;
end;          
begin
end.

57

(1 replies, posted in Script)

How To Show icon or grab bar in Tsplitter  Or Edit Script Add ?
http://melander.dk/wordpress/wp-content/uploads/2010/10/splitterlead.png

58

(1 replies, posted in General)

MVD 4.6 Export Correct all cell from tablegrid .asstring when export OK...
But
MVD 5.2 Export Not Correct all cell from tablegrid  Auto change format  when export Not OK.....

How To Fix Bug ? How to setting all cell to AsString  same Original MVD version

https://i.ibb.co/nkZ0DXc/2019-03-15-001.png

59

(1 replies, posted in Reports)

I find Using Custom Functions in a Report ? and get link
https://www.fast-report.com/documentati … report.htm

and

https://stackoverflow.com/questions/157 … streport-4
https://i.stack.imgur.com/7LcZQ.png

For MVD Can Add custom  Function  ? If Can  .... Where Edit Script add custom function  MVD Script or Fasreport  Script ?

Help Me please !

60

(7 replies, posted in General)

DriveSoft Today 17:53:43

Please attach your project, project in the first message don't have script file.

MVD 2.8
https://i.ibb.co/r78J0BR/Image-002.png
MVD 3.6
https://i.ibb.co/jVfHkqs/Image-003.png
MVD 4.6
https://i.ibb.co/vQ9895x/Image-004.png
MVD 5.2
https://i.ibb.co/XxgN5Np/Image-005.png

Help Me please !

61

(7 replies, posted in General)

Thank You jean.brezhonek I try  Code  and result

Now i try convert encode city.text by navicode  OK  Can Import To  city.text

But
I try  code Tstringlist and show Form.caption := Tstringlist[0] Error Message Out OF bound  How To Fix ???

https://i.ibb.co/ZW392d9/2019-03-01-007.png

Help ME Please !

62

(7 replies, posted in General)

help me please !
Can  import support UTF8,UTF16 ?

63

(7 replies, posted in General)

TableGrid1.LoadFromTextFile Not Effect in MVD 5.2

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
opendialog : Topendialog ;
begin
opendialog := Topendialog.Create(Form1);
IF opendialog.execute then
begin
Form1.TableGrid1.LoadFromTextFile(opendialog.Filename) ;
Form1.Memo1.Lines.LoadFromFile(opendialog.Filename) ;
end;
Form1.TableGrid1.BestFitColumns(bfboth);
opendialog.Free ;
end;
begin
end.

64

(1 replies, posted in Script)

I try find function regexp in sqlite have not
but  i try create script create script sql for search value

Can input multiple value  in one line for search by " "


IF MySQL USE  regexp

where column regexp '123|456'

Screen Short
https://i.imgur.com/1vGS1iY.png

Open Code

procedure Form1_Edit2_OnChange (Sender: TObject);
var
i : Integer ;
original_string : String;
arr_string : Array Of String ;
begin
    Form1.Memo2.Clear ;
    original_string := Trim(Form1.Edit2.Text);
    Form1.Memo2.Lines.add('SELECT * FROM city WHERE 1 = 1');
    arr_string := SplitString(original_string,' ');
    For i := 0 To Length(arr_string) -1
    Do
    Begin
        Form1.Memo2.Lines.add('AND tip LIKE "%'+arr_string[i]+'%"')
    End;
    Form1.TableGrid1.dbSQL := Form1.Memo2.Text ;
    Form1.TableGrid1.dbSQLExecute;
    Form1.TableGrid1.BestFitColumns(bfboth);
end;
begin
end.                 

65

(2 replies, posted in Reports)

Thank You very much Dmitry.

It good feature and easy use

Must try the test and will report the result further. Thank you.  Again

66

(4 replies, posted in Reports)

Example Print From Select Tablegrid

67

(2 replies, posted in Reports)

In Script MVD have good function  (Mathematical,Other ) and easy to use  but in report script have not

how to copy function in MVD To report or create custom function

https://i.ibb.co/swc6xqk/2019-02-04-001.png

68

(2 replies, posted in Reports)

Thank You  Dmitry.
For Fix  Error And Easy  use Stringlist in this problem

For MVD Community  can download "bug_report.fr3"  replace original Fix Error
https://i.ibb.co/tcNT1Bm/2019-01-31-005.png
https://i.ibb.co/MR58CqZ/2019-01-31-006.png
Script Fix

var
//sum
sList: TStringList;
si: Integer;
//count
cList: TStringList;
ci: Integer;
//max
xList: TStringList;
xi: Integer;
//min
yList: TStringList;
yi: Integer;
procedure GroupHeader1OnBeforePrint(Sender: TfrxComponent);
begin
    if Engine.FinalPass then
    if ValidInt(sList[si]) then
    Memo5.Text := 'SUM = '+FormatFloat('#,##0', StrToFloat(sList[si]));
    if Engine.FinalPass then
    if ValidInt(cList[ci]) then
    Memo10.Text := 'COUNT = '+(cList[ci]);
    if Engine.FinalPass then
    if ValidInt(xList[xi]) then
    Memo4.Text := 'MIN = '+FormatFloat('#,##0', StrToFloat(xList[xi]));
    if Engine.FinalPass then
    if ValidInt(yList[yi]) then
    Memo11.Text := 'MAX = '+FormatFloat('#,##0', StrToFloat(yList[yi]));
end;
procedure GroupFooter1OnBeforePrint(Sender: TfrxComponent);
begin
    if not Engine.FinalPass then sList.Add(FloatToStr(SUM(<Report."population">, MasterData1)));
    Inc(si);
    if not Engine.FinalPass then cList.Add(FloatToStr(count(masterdata1)));
    Inc(ci);
    if not Engine.FinalPass then xList.Add(FloatToStr(MIN(<Report."population">,MasterData1)));
    Inc(xi);
    if not Engine.FinalPass then yList.Add(FloatToStr(MAX(<Report."population">,MasterData1)));
    Inc(yi);
end;
procedure frxReportOnStartReport(Sender: TfrxComponent);
begin
    sList := TStringList.Create;
    cList := TStringList.Create;
    xList := TStringList.Create;
    yList := TStringList.Create;
end;
procedure frxReportOnStopReport(Sender: TfrxComponent);
begin
    sList.Free;
    cList.Free;
    xList.Free;
    yList.Free;
end;
procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
    si := 0;
    ci := 0;
    xi := 0;
    yi := 0;
end;
begin
end.

69

(10 replies, posted in General)

Thank You Dmitry. Again
This Example Now use Ctrl+V only can not use right click Paste
https://i.ibb.co/N7rxP1H/2019-01-28-004.png


How To Use This  Effect
Step 1 Check Form Event
https://i.ibb.co/kSywC4y/2019-01-28-002.png
Step 2 Check Script (Next Example I try modify script support Field more 2)
https://i.ibb.co/6rWRmr5/2019-01-28-003.png
Setp 3 - 4 Copy and Use Ctrl+V
https://i.ibb.co/YZfSPJk/2019-01-28-005.png

70

(2 replies, posted in Reports)

Printing a group sum in the group header
https://www.fast-report.com/documentati … header.htm
But Get Error  summary miss  group



Summary Group Header  Group(1)      To  Group(2)
....
Summary Group Header  Group(Last) To  Group(1)

procedure GroupFooter1OnBeforePrint(Sender: TfrxComponent);
begin
    Set('S', Sum(<Report."population">));  
end;

procedure Memo5OnBeforePrint(Sender: TfrxComponent);
begin
    if Engine.FinalPass then
    Memo5.Text := FormatFloat('0,000',Get('S'));  
end;

begin

end.

https://i.ibb.co/QX8ZdNb/2019-01-28-006.png

71

(10 replies, posted in General)

I want to copy value from excel to tablegrid and insert to table in database ...

excel --> tablegrid --> database

help increase speed  when input data

72

(10 replies, posted in General)

I think try use function clipboardget  and splitter string but
i don't know use even  at tablegrid ???

73

(10 replies, posted in General)

How To Copy All Value From Excel  To Grid  in MVD  By Ctrl+C ,Ctrl+V

https://i.ibb.co/gT74Q1g/2019-01-22-001.png

74

(1 replies, posted in General)

How To Setting Font Default All Component In MVD ?

  • Font Name
    Font Size

in Component

  • Button
    TextBox
    Memo
    Richedit
    Combobox
    Checkbox
    Dattimepicker
    Tablegrid
    Treeview
    Groupbox
    PageControl

75

(20 replies, posted in General)

Requirement add line number in Tmemo please ! look like script edit
https://image.ibb.co/eEjoaL/2018-11-19-002.png