OR
as you inferred it would have been like this
SumTotal = 1
While (SumTotal < 5)
SumTotal = SumTotal + 3
Wend
Here in this case 7 will be the correct answer.
Regards
Shaik Akthar
OR
as you inferred it would have been like this
SumTotal = 1
While (SumTotal < 5)
SumTotal = SumTotal + 3
Wend
Here in this case 7 will be the correct answer.
Regards
Shaik Akthar
SumTotal = 1
IF (SumTotal < 5) Then
SumTotal = SumTotal + 3
End IF
What will be the value of SumTotal when the program comes out of the loop?
a. 5
b. 7
c. 3
d. 10
It is not a loop to go back as it does in
While...Wend or For...Next . Once the Conditional Statements end they continue with the statements following afterwards. The only way to get back is to issue a 'GoTo' Statement with a condition and with some label defined above the if statement like
SumTotal = 1
CheckAgain:
IF (SumTotal < 5) Then
SumTotal = SumTotal + 3
End IF
If SumTotal < 5 Then
GoTo CheckAgain
End If
Regards
Shaik Akthar
Try This Code
'Put this declaration on the top of the Code Window of the form
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40
'Put this code in the Button_Click() event
'Or whereever u want to make the
'screen full screen.
Dim cx As Long
Dim cy As Long
Dim RetVal As Long
' Determine if screen is already maximized.
If Me.WindowState = vbMaximized Then
' Set window to normal size
Me.WindowState = vbNormal
End If
' Get full screen width.
cx = GetSystemMetrics(SM_CXSCREEN)
' Get full screen height.
cy = GetSystemMetrics(SM_CYSCREEN)
' Call API to set new size of window.
RetVal = SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW)
Hope this solves ur problem
Regards
Shaik Akthar
May I ask U What are all the Questions actually for? Are U Preparing for any Competitive Exams?
Regards
Shaik Akthar
Result= input_number Mod 7
If (Result > 0) Then
Cells(1,1).Value = 3
Else
NextResult = input_number Mod 5
If (NextResult > 0) Then
Cells(1,1).Value = 2
Else
Cells(1,1).Value = 1
End If
End If
56 mod 7 is 0. hence Else part is executed.
In the else part again 56 mod 5 is 1. so the NextResult>0 holds true, by which Cells(1,1).Value = 2 is executed.
Answer B is correct.
Public Function Discount(quantity As Integer) As Single
IF (quantity <= 5) Then
Discount = 0
Else
IF (quantity <= 10) Then
Discount = 0.1
Else
Discount = 0.15
End IF
End IF
End Function
Here the Discount(12) will result in execution of the Discount = 0.15 statement. So your answer C is correct.
SumTotal = 1
IF (SumTotal < 5) Then
SumTotal = SumTotal + 3
End IF
Since SumTotal is Less Than 5 and true, the statement SumTotal = SumTotal + 3 will be executed and the resulting value of
SumTotal = 1 + 3 = 4. i think none of the answers is right. A small clarification. You said it is a loop, but the code u gave is a condition statement not a loop. is the question typed correctly. if the question u typed is correct then none of the answers is correct because the correct answer is 4.
The answer 'A' is true because within a module or from another module u can call the procedure followed by its module name. but to call a function which is in another module, the module name where the function resides will be mandatory.
The Answer 'B' is true because you can call a function in another module if and only if it is declared as public.
The Answer 'C' is false because the radius and height are the arguments passed to the function and not the return values. And also a function can return one and only one value.
Regards
Shaik Akthar
U have to take another Variable
I = 1
N = 5
Do While I < N
Cells(1,I) = N - I
I = I + 1
Loop
Regards
Shaik Akthar
Dont open the recordset in form load event.
'in the module
Global con As New Connection
Global tel_idx As New Recordset
'in the form load event
'Also dont hardcode the database path
'con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Telephone_Index\Telephone_Index.mdb"
'Write something like this
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Telephone_Index.mdb"
'Remove this line
tel_idx.Open "tel_index", con, adOpenDynamic, adLockOptimistic
'in the command button click event
'Rest All is ok
'If opening the recordset in Form_Load() Event is required for u for some other logic then
'u must close the record set first before opening it again.
If Not tel_idx is Nothing Then
If tel_idx.State Then tel_idx.Close
End If
tel_idx.CursorLocation = adUseClient
Set tel_idx = con.Execute("SELECT * FROM tel_index where name= '" + Text17.Text + "';")
Set DataGrid2.DataSource = tel_idx
Hope this solves ur problem
Regards
Shaik Akthar
:D did u mean to say that the u got to know the problem, and the problem is because of us all?
just kidding.
can u tell how the client and server are connected. Is is Local Network, Dial-Up or something else.
U can also post some sample code for the hint of what u r actually trying to do, so that we can figure out the best possible way from what ur expectations are.
Regards
Shaik Akthar
Dim colVar As Integer
Dim noOfCols As Integer
Dim colChars As String
Dim cellAdd As String
colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
'This piece of code holds good
'for Columns upto 26 only
'Because beyond that the col names will
'be AA, AB, AC,...
'Then u may have to create and array
'using a loop to store the column names
noOfCols = 10
For colVar = 1 To noOfCols
cellAdd = Mid(colChars, colVar, 1) & 1
Range(cellAdd).Value = noOfCols - colVar + 1
Next colVar
Hope this solves ur problem.
Dear herephishy,
plz dont break the thread. continue ur queries in the previous thread itself. so that u can get all ur related solutions in one single thread. this is just a piece of advice. hope i didn't say anything wrong
Regards
Shaik Akthar
Dear herephishy,
plz dont break the thread. continue ur queries in the previous thread itself. so that u can get all ur related solutions in one single thread. this is just a piece of advice. hope i didn't say anything wrong
Regards
Shaik Akthar
Dim colVar As Integer
Dim noOfCols As Integer
Dim colChars As String
Dim cellAdd As String
colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
'This piece of code holds good
'for Columns upto 26 only
'Because beyond that the col names will
'be AA, AB, AC,...
'Then u may have to create and array
'using a loop to store the column names
noOfCols = 10
For colVar = 1 To noOfCols
cellAdd = Mid(colChars, colVar, 1) & 1
Range(cellAdd).Value = noOfCols - colVar + 1
Next colVar
Hope this solves ur problem.
Regards
Shaik Akthar
Check out the Example attached.
Regards
Shaik Akthar
There r so many ways to loop.
Try this one.
Dim colVar As Integer
Dim colChars As String
Dim cellAdd As String
colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
For colVar = 1 To 4
cellAdd = Mid(colChars, colVar, 1) & 1
Range(cellAdd).Value = colVar
Next colVar
Hope this solves ur problem.
Regards
Shaik Akthar
I think u can get some clue from this following thread, please have a look at it and if solves ur need, please post the reputation of the solution to the poster hell_tej.
http://www.daniweb.com/forums/thread140360.html
Let me know if there is something else than this is what u need along with the Backend and Crystal Reports Version u r using.
Regards
Shaik Akthar
Dear Breezyy
The Asc() function returns the ascii value of only one character at a time. If u want to get the ascii values of a group of characters, u have to use the Asc() for each character one at a time. U can use For...Next to loop thru the characters of the string.
Dim xStr as String
Dim iVar as Integer
Dim tStr as Long
tStr =0
xStr = "Mark"
For iVar = 1 to Len(xStr)
tStr = tStr + Asc(Mid(xStr,iVar,1)
Next iVar
But i dont get the point in saving ascii codes in the DB. if u join all the asc code of a string, how would u create an Unique ID. For eg if ABCD will result in 65+66+67+68=266 then XZX also results in 88+90+88=266. The how can there be uniqueness? I am actually not sure whether i have understood ur concept or not, but that is the doubt i had. Any How all the best dear. hope it solves ur problem
Regards
Shaik Akthar
I guess it is c) -1
Yes surely u can use crystal reports. What is the Database u r using? Is it MS-Access or SQL Server or other. If u r stuck up at any point just post the code at which u r stuck up with. will try to do the needful.
Also can u tell me the version of crystal reports u r using.
Regards
Shaik Akthar
Hi,
Plz chk out the sample project i have given here as attachment. it may help u get some logic.
u need not query the database each time u want to search. fill the flexgrid once when form loads and then use that static data to find the rows with your search values af any required column.
Hope this may help u.
Regards
Shaik Akthar
ok. sorting out the problem. just a few minutes plz.
Regards
Shaik Akthar
Ok. I think that you have the recordset declared globally and accessing the recordset in the dload procedure to fill the FlexGrid. then the problem with it is;
1. you are not opening the recordset in the cmdSearch_Click() event.
2. you are setting the recordset to nothing the the cmdSearch_Click() at the end which closes the recordset if open.
may be i can help u with this
Private Sub cmdSearch_Click()
On Error GoTo errhan
'Close the recordset if open first before searching
If Not rst Is Nothing Then
if rst.state then rst.close
Set rst = Nothing
End If
'Instantiate again
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
SQL = "Select * from profile2 where name like '" & Trim(fldSearch.Text) & "%'"
'Open the recordset
rst.Open SQL, con, adOpenKeyset, adLockReadOnly
'Now u can call this procedure and get the recordset to work without error
'because it is not yet closed
Call dload
exitPoint:
Exit Sub
errhan:
MsgBox "Err No : " & Err.Number & vbCrLf & Err.Description
'Put the error control code here to close recordset if any error occurs
If Not rst Is Nothing Then
if rst.state then rst.close
Set rst = Nothing
End If
Resume exitPoint
End Sub
Private Sub dlload()
MSFlexGrid1.Clear
While Not rst.EOF
'replace field1,field2 etc with the fields u want
MSFlexGrid1.addItem rst!field1 & vbTab & rst!field2
rst.MoveNext
Wend
End Sub
hope it solves ur problem.
Regards
Shaik Akthar
To On/Off a checkbox the Value property of the Checkbox is used. If the value=1 then it is ticked, if value=0 then the tick is removed.
suppose u get the value of some column say 'RoomAvail' from a ms-access table into the recordset say 'rst'
then u can write the code for the checkbox something like this
CheckBox1.Value = IIf(UCase(rst!RoomAvail) = "YES",1,0) 'Availabe CheckBox
CheckBox2.Value = IIf(UCase(rst!RoomAvail) = "NO",1,0) 'Not Availabe CheckBox
OR
If UCase(rst!RoomAvail) = "YES" Then
CheckBox1.Value = 1 'Available CheckBox
CheckBox2.Value = 0 'Not Availabe CheckBox
Else
CheckBox1.Value = 0 'Available CheckBox
CheckBox2.Value = 1 'Not Availabe CheckBox
End If
Regards
Shaik Akthar
I dont know whether this can help u or not, but plz take a look at the attached excel file here.
Regards
Shaik Akthar
To limit the entry of more than one letter, just set the maxlength property of the textbox to 1.
to limit the entry of characters from "a through z" only use the
TextBox_KeyPress() event.
Mr. jonifen u have a good knowledge of VB. its gr8. try to make the game more interesting. you have made the hangman to appear letter by letter. ok. if the word is only 4 letters long? what if the word would have to be 7 letters long? i am also trying out a little bit on this. u can plz find some better soln very soon from me.
regards,
Shaik Akthar
Try this.
Private Sub cmdSearch_Click()
On Error GoTo errhan
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
SQL = "Select * from profile2 where name like '" & Trim(fldSearch.Text) & "%'"
rst.Open SQL, con, adOpenKeyset, adLockReadOnly
MSFlexGrid1.Clear
While Not rst.EOF
'replace field1,field2 etc with the fields u want
MSFlexGrid1.addItem rst!field1 & vbTab & rst!field2
rst.MoveNext
Wend
Call dload
exitPoint:
If Not rst Is Nothing Then
if rst.state then rst.close
Set rst = Nothing
End If
Exit Sub
errhan:
MsgBox "Err No : " & Err.Number & vbCrLf & Err.Description
Resume exitPoint
End Sub
can u tell me what is this dload procedure?
Dear All,
Plz focus on the exact problem.
When u r posting in this forum, first do give the backend u r using, table structure if possible, some sample code in front end which u r having problem with. 'll definitely help us to help u all.
regards
Shaik Akthar
Please focus precisely on the problem. Are you using Visual Basic IDE or the VBA in MS-Access? What mode are you using to connect to the data?
If u can place some sample code with which u have tried and failed, then maybe it would be more helpful for me to understand the problem and help u precisely on the issue you are facing problem with.
The Range() uses a string for selection of a range of cells.
you can use like this for eg:
Dim i as integer
Dim n as integer
n = 100 'The last row
For i = 5 to n
Range("A" & i).Select
If ActiveCell <> "" Then
ActiveCell.Select
Selection.Copy
'If the cell has a Department, copy it'
ActiveCell.Offset(1, 0).Select
If ActiveCell = "" Then
ActiveSheet.Paste
'paste the department numbers on the rows without it.'
ElseIf ActiveCell Like "Totals*" Then
'delete the Company Totals Rows'
Rows(ActiveCell.Row).delete
'Decrease the last row count
'because a row is deleted
n = n - 1
ActiveCell.Select
End If
End If
Next i
Still more effective solution can be done.
First you may need to iterate through all the processes running in the memory to check whether at all if excel is running.
If it is not running then u may create the new instance of the excel application and open your file as usual.
if it is already running, then get the application handle to the excel application already open and check whether ur file to be opened is already opened or not. if yes then display "File Already Open" message, else open the file.
go for some googling at google.com for help regarding iterating through the running processes, getting the window handles of the applications and attaching them to objects, etc.
good luck.
U Work a Little, We Guide U a Little.
Check Out this code. it may be of some help. i'll give still more effective code later on if u r not able to get what u need. try to use the logic from the sample code given here.
Option Explicit
Private xlTemp As Excel.Application
Private sFileName As String
Private Sub cmdOpen_Click()
On Error GoTo cmdOpen_Click_Error
Set xlTemp = New Excel.Application
sFileName = "C:\TEST.XLS"
If Dir(sFileName) <> "" Then
xlTemp.Workbooks.Open sFileName
xlTemp.Visible = True
Else
MsgBox "File Not Found."
End If
cmdOpen_Click_Done:
Exit Sub
cmdOpen_Click_Error:
MsgBox "An Error has occured in Procedure cmdOpen_Click." & vbCrLf & Err.Number & " : " & Err.Description & vbCrLf & vbCrLf & "Contact System Administrator."
Resume cmdOpen_Click_Done
End Sub
Private Sub cmdClose_Click()
Dim ret As Integer
Dim nFiles As Integer
Dim iVar As Integer
On Error GoTo cmdClose_Click_Error
If Not xlTemp Is Nothing Then
If xlTemp.Visible Then
nFiles = xlTemp.Workbooks.Count
For iVar = 1 To nFiles
If UCase(xlTemp.Workbooks(iVar).Path & "\" & xlTemp.Workbooks(iVar).Name) = UCase(sFileName) Then
xlTemp.Workbooks(iVar).Close
If nFiles = 1 Then 'Confirm that no other workbooks are open and then quit
xlTemp.Quit
End If
Exit For
End If
Next
End If
End If
cmdClose_Click_Done:
Exit Sub
cmdClose_Click_Error:
MsgBox "An Error has occured in Procedure cmdClose_Click." & vbCrLf & Err.Number & " : " & Err.Description & vbCrLf & vbCrLf & "Contact System Administrator."
If Not xlTemp Is Nothing Then
If xlTemp.Visible Then
xlTemp.Workbooks.Close
xlTemp.Quit
End If
End If
Set xlTemp = Nothing
Resume cmdClose_Click_Done
End Sub
First you may need to iterate through all the processes running in the memory to check whether at all if excel is running.
If it is not running then u may create the new instance of the excel application and open your file as usual.
if it is already running, then get the application handle to the excel application already open and check whether ur file to be opened is already opened or not. if yes then display "File Already Open" message, else open the file.
go for some googling at google.com for help regarding iterating through the running processes, getting the window handles of the applications and attaching them to objects, etc.
good luck.
U Work a Little, We Guide U a Little.
Check Out this code. it may be of some help. i'll give still more effective code later on if u r not able to get what u need. try to use the logic from the sample code given here.
Option Explicit
Private xlTemp As Excel.Application
Private sFileName As String
Private Sub cmdOpen_Click()
On Error GoTo cmdOpen_Click_Error
Set xlTemp = New Excel.Application
sFileName = "C:\TEST.XLS"
If Dir(sFileName) <> "" Then
xlTemp.Workbooks.Open sFileName
xlTemp.Visible = True
Else
MsgBox "File Not Found."
End If
cmdOpen_Click_Done:
Exit Sub
cmdOpen_Click_Error:
MsgBox "An Error has occured in Procedure cmdOpen_Click." & vbCrLf & Err.Number & " : " & Err.Description & vbCrLf & vbCrLf & "Contact System Administrator."
Resume cmdOpen_Click_Done
End Sub
Private Sub cmdClose_Click()
Dim ret As Integer
Dim nFiles As Integer
Dim iVar As Integer
On Error GoTo cmdClose_Click_Error
If Not xlTemp Is Nothing Then
If xlTemp.Visible Then
nFiles = xlTemp.Workbooks.Count
For iVar = 1 To nFiles
If UCase(xlTemp.Workbooks(iVar).Path & "\" & xlTemp.Workbooks(iVar).Name) = UCase(sFileName) Then
xlTemp.Workbooks(iVar).Close
If nFiles = 1 Then 'Confirm that no other workbooks are open and then quit
xlTemp.Quit
End If
Exit For
End If
Next
End If
End If
cmdClose_Click_Done:
Exit Sub
cmdClose_Click_Error:
MsgBox "An Error has occured in Procedure cmdClose_Click." & vbCrLf & Err.Number & " : " & Err.Description & vbCrLf & vbCrLf & "Contact System Administrator."
If Not xlTemp Is Nothing Then
If xlTemp.Visible Then
xlTemp.Workbooks.Close
xlTemp.Quit
End If
End If
Set xlTemp = Nothing
Resume cmdClose_Click_Done
End Sub
You may still have to validate if the data entered in the input box is in the expected date format or not and then go for updating the cell in the WorkSheet. Because a mere inputbox will allow me to enter any garbage, meaningless data also.
Confirm that the Regional Settings in the control panel also has the dd/MM/yy setting of the system whenever u r placing this excel file in another new system.
Just check out this code here. I have modified your code in Module2 in procedure Enter_FOAP()
Sub Enter_FOAP()
Dim xDate As Date
Sheets("Figures").Select
ActiveSheet.Unprotect
Range("N1").Select
w = InputBox("Enter Voyage No. i.e. IH0603-106L")
ActiveCell.Value = w
Range("b6").Select
xDate = InputBox("Enter date & time for FAOP i.e. 01/01/06 12:00", "Date Time for FAOP", Format(Now, "dd/MM/yy hh:nn"))
' x = InputBox("Enter date & time for FAOP i.e. 01/01/06 12:00")
ActiveCell.Value = xDate
Range("o6").Select
xDate = InputBox("Enter date & time for ETA Singapore i.e. 01/01/06 12:00")
ActiveCell.Value = xDate
Range("t6").Select
xDate = InputBox("Enter date & time for ETA Japan i.e. 01/01/06 12:00")
ActiveCell.Value = xDate
End Sub
regards,
Shaik Akthar
Working with it plz wait. 'll provide the solution asap
Also many articles regarding Visual Basic Techniques can be found here.
http://www.devarticles.com/c/a/Visual-Basic/
I have also attached a Word File extracted from the above website for a little reference of Printing in VB6
As far as i know, u can open the printer properties and change the paper orientation to landscape manually.
Then if you try to print u will get the out in landscape itself.
Else otherwise use the Printer Object wherein u can manage all the printer settings. the code which u referred is the setting of the Printer Object which works if u print using the Printer Object.
For more details refer to.
http://msdn.microsoft.com/en-us/library/aa267233(VS.60).aspx
Also a little information is attached in the Word file i have attached here
Just put the following line in the
btnSave_Click() event
Private Sub btnSave_Click()
'This subroutine writes data to the database
Dim objDB As Database
Dim objRS As Recordset
Dim InputIndex As Double
Dim InputName As String
Dim InputMin As Double
Dim InputMax As Double
Dim InputPLC As String
Dim SelectedInput As String
Dim Count As Long
On Error GoTo Error_Handler
'******************************* Write to Db **************************
'Connect to database
'Break the selected input into variables
SelectedInput = glbInput
SelectedInput = Right(SelectedInput, Len(SelectedInput)) 'Trim initial tab
Count = InStr(1, SelectedInput, vbTab)
InputIndex = Left(SelectedInput, Count - 1) 'Index
SelectedInput = Right(SelectedInput, Len(SelectedInput) - Count)
Count = InStr(1, SelectedInput, vbTab)
InputName = Left(SelectedInput, Count - 1) 'Name
SelectedInput = Right(SelectedInput, Len(SelectedInput) - Count)
Count = InStr(1, SelectedInput, vbTab)
InputMin = Left(SelectedInput, Count - 1) 'RawMin
SelectedInput = Right(SelectedInput, Len(SelectedInput) - Count)
Count = InStr(1, SelectedInput, vbTab)
InputMax = Left(SelectedInput, Count - 1) 'RawMax
SelectedInput = Right(SelectedInput, Len(SelectedInput) - Count)
Count = InStr(1, SelectedInput, vbTab)
InputPLC = Right(SelectedInput, Len(SelectedInput) - Count) 'Grouping
'Retrieving all values from database
Set objRS = glbCurrentDB.OpenRecordset("SELECT * FROM [tblInput] WHERE ([Index] = " & InputIndex & ")", dbOpenDynaset)
objRS.Edit
'objRS![Index] = txtIndexNum
objRS![Name] = txtName
objRS![RawMin] = Val(txtMin)
objRS![RawMax] = Val(txtMax)
objRS![PLC] = txtPLC
objRS.Update
'Clear database from memory.
Set objRS = Nothing
'Set value for list highlight
[B][I]'Also here remove the first vbtab[/I][/B]
glbInput = [B][I]vbTab &[/I][/B] txtIndexNum & vbTab & txtName & vbTab & Val(txtMin) & vbTab & Val(txtMax) & vbTab & txtPLC
lstInput.List(lstInput.ListIndex) = glbInput …
Try this sample project uploaded here and see if it can help u in any way. its from the site www.vb6.us. u can find more samples on pdf's at this site.
plz state the problem much clearly. give some sample code which u have tried and failed. do u want to print the textfile content to a Dot Matrix Printer in DOS Mode? Do u want a formatted windows based output of the textfile content?
For VB.NET another version of the solution is provided here.
Imports System
Imports System.Data.OleDb
Module Module1
Sub Main()
Dim cn As OleDbConnection
cn = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=C:\;" & _
"Mode=Share Deny None;Extended Properties="""";User ID="""";" & _
"Mask Password=False;Cache Authentication=False;EncryptPassword=False;" & _
"Collating Sequence=MACHINE;Exclusive=ON;DSN=""""")
Dim cmd As OleDbCommand = New OleDbCommand("Pack TestPack", cn)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
Catch e As Exception
MsgBox("Exception")
End Try
End Sub
End Module
DONT USE ODBCCONNECT ---- USE THE OLEDBCONNECTION ABOVE, OTHERWISE IT MAY
HANG WHEN PACKING
HERE'S A SAMPLE OF WHAT NOT TO DO
Dim cn As OdbcConnection
cn = New OdbcConnection("Driver={Microsoft Visual
FoxProDriver};SourceType=DBF;SourceDB=c:\dbfpath;")
Dim mystring As String = "SET EXCLUSIVE ON;PACK Table1"
Dim cmd As OdbcCommand = New OdbcCommand(mystring, cn)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
this can be found at the following url:
http://visualbasic.ittoolbox.com/groups/technical-functional/visualbasic-l/pack-a-foxpro-dbf-v50-table-from-visual-basic-621677
For VB.NET another version of the solution is provided here.
Imports System
Imports System.Data.OleDb
Module Module1
Sub Main()
Dim cn As OleDbConnection
cn = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=C:\;" & _
"Mode=Share Deny None;Extended Properties="""";User ID="""";" & _
"Mask Password=False;Cache Authentication=False;EncryptPassword=False;" & _
"Collating Sequence=MACHINE;Exclusive=ON;DSN=""""")
Dim cmd As OleDbCommand = New OleDbCommand("Pack TestPack", cn)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
Catch e As Exception
MsgBox("Exception")
End Try
End Sub
End Module
DONT USE ODBCCONNECT ---- USE THE OLEDBCONNECTION ABOVE, OTHERWISE IT MAY
HANG WHEN PACKING
HERE'S A SAMPLE OF WHAT NOT TO DO
Dim cn As OdbcConnection
cn = New OdbcConnection("Driver={Microsoft Visual
FoxProDriver};SourceType=DBF;SourceDB=c:\dbfpath;")
Dim mystring As String = "SET EXCLUSIVE ON;PACK Table1"
Dim cmd As OdbcCommand = New OdbcCommand(mystring, cn)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
this can be found at the following url:
http://visualbasic.ittoolbox.com/groups/technical-functional/visualbasic-l/pack-a-foxpro-dbf-v50-table-from-visual-basic-621677
To be able to ZAP or PACK your .DBF files, you must have the following entry in your VB.INI or <appname>.INI file:
[dBase ISAM]
Deleted=On
This will filter out deleted records so they do not appear in recordsets.
To perform a ZAP, you simply need to run a DELETE action query. For example, the following sample marks all the records in the AUTHORS.DBF table as deleted:
Dim db As database
Set db = OpenDatabase("c:\dBaseIII", false, false, "dBase III")
'Open the database.
db.Execute "Delete From Authors" 'Execute the delete action query.
db.Close 'Close the database.
NOTE: For extremely large tables, it is more efficient to delete the Tabledef representing the table from the TableDefs collection of the database and then re-create the table structure.
The following subroutine shows you how to perform a PACK. Essentially, you copy all the records to a new temporary table, delete the old one, then rename the temporary table as the original name.
Private Sub Pack_DBF (db As Database, tblname As String)
Const MB_YESNO = 4 ' Yes and No buttons
Const MB_ICONEXCLAMATION = 48 ' Warning message
Const IDYES = 6 ' Yes button pressed
Dim dbdir As String, tmp As String 'Temp variables
Dim i As Integer, ret As Integer 'Counter and return value of MsgBox
Dim flags As Integer 'Flags for MsgBox
ReDim idxs(0) As New index 'Holds indexes
On Error GoTo PackErr
flags = MB_YESNO Or MB_ICONEXCLAMATION
ret = MsgBox("Remove All Deleted Records in " …
Check this
Another suggestion, use MSHFlexGrid (Heirarchial FlexGrid to populate the records of the recordset. U need not use the loop to populate the records. just use
Open the recordset as KeySet
rst.Open QryString, con, adOpenKeyset
Set MSHFlexGrid1.Recordset = rst
No. But i added a query there named CREATENEWTAB
Also check out the field names in your database and the code. i had changed the field names here by appending _Attr to last three fields, because type, value etc may be some keywords or reserved VB words.
give some hint with the sample code u want to solve for.
Apart from that some of vb basic commands are there to get any substring from a string
1. Left(string, n) gets n number of characters from the left of the string
2. Right(string, n) gets n number of characters from the right of the string
3. Mid(string,m,n) gets n number of characters starting from the mth character of the string.