| | |
Boolean checking
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: May 2006
Posts: 39
Reputation:
Solved Threads: 0
Hi Guys,
Below is a code that searches for a value in a cell in excel. I want a code that would check to see if the word has been found or not. When I do the search and the word is not found, I get an error message " Object Variable or With block variable not set".
I know the above message comes up only when the word is not found. How can I by pass this inorder to tell the user through a message box that the document does not exist. That way the will be able to create a new record.
INI
Below is a code that searches for a value in a cell in excel. I want a code that would check to see if the word has been found or not. When I do the search and the word is not found, I get an error message " Object Variable or With block variable not set".
I know the above message comes up only when the word is not found. How can I by pass this inorder to tell the user through a message box that the document does not exist. That way the will be able to create a new record.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
word = frmSearch.txtEnterDate.Text If frmSearch.cboSystems.ListIndex = 0 Then Sheets("Current").Select Range("A1").Select 'Selection.End(xlDown).Select Range("A1:A65536").Find(What:=word, LookAt:=xlWhole, LookIn:=xlValues, SearchOrder:=xlByColumns).Activate
INI
•
•
Join Date: May 2006
Posts: 39
Reputation:
Solved Threads: 0
Never mind guys
, I think I figured it out ! I had to insert the error handler and it work.
, I think I figured it out ! I had to insert the error handler and it work. Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim power As Variant word = frmSearch.txtEnterDate.Text If frmSearch.cboSystems.ListIndex = 0 Then Sheets("Current").Select Range("A1").Select 'Selection.End(xlDown).Select On Error GoTo ErrorHandler Range("A1:A65536").Find(What:=word, LookAt:=xlWhole, LookIn:=xlValues, SearchOrder:=xlByColumns).Activate ErrorHandler: power = CVErr(Err.Number) If IsError(power) Then MsgBox ("Word not found") End If End If
Last edited by INI; Jun 15th, 2006 at 11:40 am.
ctrl-printscreen seems to copy a screenshot (in XP anyways) to the clipboard..... then you can run mspaint (start run mspaint) and paste it into paint, in which case you can manip the image...... then when posting your thread (in advanced mode) there is an option to attach a file.... save the file in mspaint and attach it in the thread.....voila.
•
•
Join Date: May 2006
Posts: 39
Reputation:
Solved Threads: 0
Never mind guys
, I think I figured it out ! I had to insert the error handler and it work.
, I think I figured it out ! I had to insert the error handler and it work. Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim power As Variant word = frmSearch.txtEnterDate.Text If frmSearch.cboSystems.ListIndex = 0 Then Sheets("Current").Select Range("A1").Select 'Selection.End(xlDown).Select On Error GoTo ErrorHandler Range("A1:A65536").Find(What:=word, LookAt:=xlWhole, LookIn:=xlValues, SearchOrder:=xlByColumns).Activate ErrorHandler: power = CVErr(Err.Number) If IsError(power) Then MsgBox ("Word not found") End If End If
Last edited by Comatose; Jun 15th, 2006 at 8:16 pm.
![]() |
Similar Threads
- error checking (Java)
- Boolean Algebra (C++)
- Recursive prime number f(x) (C)
- How to Perform Disk Error Checking in Windows XP (Windows tips 'n' tweaks)
- Need some help with a Java lab... (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: error handling in VB6 + + ODBC + MySQL...(Help!!!!)
- Next Thread: Sort a dynamic array of structs
Views: 2206 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






