Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How Can I Check If An Object Equal To Null


I set an Object and i want to check
if the object is null or not
How can i do it?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do You Check To See If An Object Is Equal To Nothing?
' this works:
Set MyObject = Nothing

'but this doesn't:
If MyObject = Nothing then
do_this
endif

So...
How do you check to see if an object is equal to nothing?

Setting An Object Equal To Another Object (quick Question)
if i were to do this:


VB Code:
Dim m_obj As ADODB.Connection Public Property Let Blah(pNewObject As ADODB.Connection)  Set m_obj = pNewObjectEnd Property


would m_obj then be the same connection that i pass in to the property, or would it be the same as creating a completely new instance?

thanks

SOLVED: How To Check If 2 Variables Are Not Equal?
in an If conditional statement, how can I check if a variable is or is not equal to 1?

Is this correct syntax?


VB Code:
If done Is Not 1 Then' code goes here'End If

Object Is Equal To Nothing
In ASP I have a object call objtemp.
I have a function that return stuff to the object. Sometimes the function doesn't return anything. I need a way to check the obj for NOTHING. I tried using if objtemp = NOTHING and
If objtemp = "Nothing" and I even tried the IsEmpty method. Is there a way for this???
Thank You

Can I Separate A Report's Data By Two Kind, Equal To And Not Equal To.
Hi,
Here I have a simple question . I have a report which will get data from two table.In the detail field. I want to separate it into two part of data. and this two part will separate by a line or any thing can identify it..
I try to do in Datapart by this way.
Two fiels I need for filter is SID and Unit.
A and B are table name.
Command 1:
Select A.Name ,B.* from A,b where A.SID =B.SID and B.SID=? and B.Unit=?
child Command :
select * from B where and B.SID like ? and B.Unit unlike ?
The command works but nothing come out at the details of report.(It has data in the recordset)
Does anybody have experience about. If I use crystal report to do it. Will it be easier.
If anybody can give me some idea, it will be very great!

millions of thanks!



wky086

When Double Are Equal But Evaluate To Not Equal???
Here is a question. Why does this print my debug message?

strBegBal = "-5697.27"
strMnthTrans = "-2534.13"
strEndBal = "-8231.40"


Code:
Dim dblBegBal As Double, strBegBal As String
Dim dblMnthTrans As Double, strMnthTrans As String
Dim dblEndBal As Double, strEndBal As String
strBegBal = Format(strBegBal , "##########0.00")
strMnthTrans = Format(strMnthTrans , "##########0.00")
strEndBal = Format(strEndBal , "##########0.00")
dblBegBal = CDbl(strBegBal)
dblMnthTrans = CDbl(strMnthTrans)
dblEndBal = CDbl(strEndBal)

If (dblBegBal + dblMnthTrans) <> dblEndBal Then
''there is an error
Debug.Print "ERROR"
End If


What am I doing wrong?


Thanks...

Null Check
I'm trying to pull some values out of a SQL db and whenever I pull a field out with a NULL in it, it crashes and says

"Item cannot be found in the collection corresponding to the requested name or ordinal"

The column names match so I don't get it. I've tried to test for NULL using isNull with no prevail. Any other suggestions?

Check Null Value
If I try to run this query in VB with my ADODB.Command show me error "IIf function is not recongnized"

INSERT INTO Table2 ( Col4, Col5 )
SELECT Table1.Col1, IIf([Table1].[Col2]=Null,[Table1].[Col2],[Table1].[Col3]) AS Expr
FROM Table1;

Actually, what I need here is:
Send data from one table to another, but if Col2 is null send column 3


Does anybody have better idea how I can make this?

Have To Check For Null
What I am trying to do in Access is to send an email using to and cc, right now if there is an address in Contact_1_Email and Contact_2_email, it will open the new message screen and allow me to send the email, but if either of the fields are blank, it won't allow me to. I know that I have to check for null in the Contact_1_email and the Contact_2_email, but I don't know how to do it or where to put it. Any help will be great.

Thanks

code that I am using follows




Code:
Private Sub ordprod_Click()
'** Begin Code

Dim stremail As String
Dim ccmail As String
Dim strbody As String

'**create variables for Outlook
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

''*gathers information from your form. This sets the string variable
''*to your fields

stremail = Contact_1_Email
ccmail = Contact_2_Email
custname = Contact_1_Name
Jobnum = Our_Job_Number
POnum = Customer_POnum
strbody = "Dear " & custname & "," & Chr(13) & Chr(13)

strbody = strbody & "Your order with PO Number: " & POnum & " for the following part/parts has entered production:" & Chr(13) & Chr(13)
strbody = strbody & Notes & Chr(13) & Chr(13)
strbody = strbody & "You will receive a follow up e-mail informing you of the date your order will be shipped." & Chr(13) & Chr(13)
strbody = strbody & "Best Regards, " & Chr(13) & Chr(13) & Chr(13)
strbody = strbody & "Adam Kehoe" & Chr(13)
strbody = strbody & "Business Development" & Chr(13)
strbody = strbody & "Protocase Inc." & Chr(13)
strbody = strbody & "Ph 1-866-849-3911" & Chr(13)
strbody = strbody & "Fax (902) 567-3336" & Chr(13)
strbody = strbody & "Email: [email]adam@protocase.com[/email]" & Chr(13)
strbody = strbody & "www.protocase.com" & Chr(13)
strbody = strbody & "Redefining Enclosures for the Electronics Industry" & Chr(13)

''*creates an instance of Outlook

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

''*creates and sends email

With objEmail
.To = stremail
.CC = ccmail
.Subject = "Your Order has entered into production"
.Body = strbody
.Display 'sends the email in outlook. Change to display if you want to be able to
'modify or see what you have created before sending the email
End With

''**closes outlook
objOutlook.Quit
Set objEmail = Nothing

Exit Sub
'*****End code****
End Sub

How Can I Check For Null Key?
Hi all,

How can i valid any nulls key on textboxes on a form? For example I have a few required fields which I need the users to enter all them before saving the records into the database.

How can I prompt the user and stop any updating into the system.

Let me give a try, hope you guy can furthur improve and provide with more better suggestion to my coding below.

If text1.text or text2.text = "null"
messagebox("Please enter the required field before saving", vbinformation, "Empty text")
Else
Continue
Endif

I like to check, is it possible to provide the user where are the missing fields that need to be entered. i.e I have more than 4 required fields.

Thanks

Check Null
Hi, all



I need help, how to identified if some field in record is null or empty r
never been fill before.



For example : i took a record which contains 3 field (a,b and c) and fied a
="aaa" and b=2005 and c is null



how to check c is null



if adoreco!c = vbnull then





thanks all



Hok Sun

ADO 2.6: Check For Null Value
Using VB 6 and ADO 2.6, what do you recommend a way to check for null value of a nullable field?

I am currently using this method, but am not sure if it's a good practice:
Code:Dim strMyValue As String
strMyValue = IIf(VarType(RS("field1")) = vbNull, "", RS("field1"))

I personally want to avoid using variants.

Check For Null Value In SQL
Is there any way to check for a null value in SQL, like in a WHERE statement? I did a search on this and I couldnt quite find what I need.

Code:SELECT RootName, Customer FROM Root Where RootName ='" & Replace(txtCompanyName.Text, "'", "''") & "' AND Customer = Null


What do I use for the conditional statement instead of the red Null?

Or is there another function for this?

 Overspecialize and you breed in weakness.

Edited by - Zargon23 on 7/24/2002 12:28:15 PM

Check If Textbox Value Is NULL
how can I check if the textbox did not has any entry?

If txtSearchFlightDestination.Text <> "" And txtSearchFlightDate.Text = "" Then
query = "SELECT * FROM FLIGHT WHERE FL_ARRIVE = '" & txtSearchFlightDestination.Text & "'"
ElseIf txtSearchFlightDestination.Text = "" And txtSearchFlightDate.Text <> "" Then
query = "SELECT * FROM FLIGHT WHERE FL_DATE = #" & Format$(txtSearchFlightDate.Text, "dd/mm/yyyy") & "# "
Else
query = "SELECT * FROM FLIGHT WHERE FL_DATE = #" & Format$(txtSearchFlightDate.Text, "dd/mm/yyyy") & "# AND FL_ARRIVE = '" & txtSearchFlightDestination.Text & "' "
End If
rd.Open query, cn, adOpenForwardOnly, adLockReadOnly

This code does not work. The situation here is there are 2 textbox.

If the user enter either data in TxtBox1 or TxtBox2....then the data can be retrieve from the database but........if both of the txtBox are empty....then it will trigger the last ELSE........the error occurs at the rd.Open

Can anybody help?

Check If String Has Null Value
i know this maybe a dumb question but i am unable to do this... why oh why i have this module thats reads value from ini file. i want my vb program to prompt for my configuration forn if an empty value in one of the parameters are found. so far i tried to check for null value "" and also tried isempty() or isnull() but still not working. i tried this:


Code:

Dim test as String

test = ReadConfigurationEntry(Section, Key) ' from a module i use

If test="" then
msgbox "Incomplete"
Else
msgbox "Complete"
End If
i tried to use len() but still test variable seems to generate a value(if 0 then empty otherwise not null). the only way i am able to check whether the value is null is to make variable a textbox object and then check the value. i know that there is a better way to do this. please help.

Thanks,

Check For Null Date
I'm working on a small project that takes data from one odbc source and puts in another odbc source. One of the fields is a date field that is possibly null and I need to check that, set it to todays date, and insert it into the new db.

My question is, how do check for a null date? Here is a code snippet of what I'm doing now.

If rstMARecords!dob = Null Then
dateTheDate = Date
Else
dateTheDate = rstMARecords!dob
End If

With the above code, I just get "invalid use of Null" because even if rstMARecords!dob is null, it skips the if statement and marches on. When I put my mouse over rstMARecords!dob, the tool tip says = Null. What gives!?

How To Check A String Whether Is NULL Or Not ?
i want to check a string or a number which is Null or not,
but VB seems not let me to compare.

i tried like this :

a = Null
if a = Null then
a = 3
end if
print a

the result will be Null , not 3 , why?

Check For Null Value In 10 Textboxes
Hi ,

I have 10 text boxes. i need to check whether the user has put sum data in these text boxes are not.
it can be done by using multiple text1.text="" , but i need a shorter method .

Please help
sars



Edited by - sars on 11/3/2006 12:50:35 AM

How To Check If Your Next Entry Is Equal To The Previous Entry
hi,
im doing an accounting system where i can input my transaction debit and credit...as we all know, these values must be equal as entered..now i want to trap whether the user input another value other that what he input on the previous entry...

here's my code:


Code:


Private Sub cmdOK_Click()
Dim dcRS As New ADODB.Recordset

strSQL = "Select * from tblEntry Where TransID like '" & trans_id.Caption & "'"
Call SelSQL(strSQL, dcRS)

If optdebit.Value = True Then
dcRS.AddNew
dcRS!TransID = trans_id.Caption
dcRS!Entries = txtTitle
dcRS!Debit = txtAmount
dcRS!Credit = 0
dcRS.Update

ElseIf optcredit.Value = True Then


dcRS.AddNew
dcRS!TransID = trans_id.Caption
dcRS!Entries = txtTitle
dcRS!Debit = 0
dcRS!Credit = txtAmount
dcRS.Update

End If

MsgBox "Transaction saved", vbInformation
Set DataGrid1.DataSource = dcRS

Private Sub Form_Load()
Dim lRS As New ADODB.Recordset

Call DataOpen(goConn)
Call LoadDataComboBox("tblAccountEntry", dbCode)

strSQL = "Select * from tblEntry Where TransID like '" & trans_id.Caption & "'"
lRS.Open strSQL, goConn, adOpenDynamic, adLockOptimistic

If Not lRS.EOF Then lRS.MoveLast
Set DataGrid1.DataSource = lRS

End Sub

End Sub


in this code i can input the data but i cant seem to trap the value of the debit if it is equal to credit on my next entry...my controls are optcredit,optdebit (radio buttons), txtamount and a command button....anyone can show me how?? thanks

Check Range Is Empty / Null
hi,
searched the forum for 2 hours, but i'm stuck.
i want to check a range if its empty, if it is: go to next range, else do other stuff.
the first range it checks is empty, i'm pretty sure, but it keeps trowing me into True(not empty). tried isnull, isempty, "".
what am i doning wrong??
part of the code:


Code:
If not IsNull(Worksheets(ListBox1.Value).Range(Cells(b, onpipe), Cells
(e, onpipe))) Then
onp = True
Else
onp = False
Exit For
end-if

thanx in advance for any help!

Check Database Field For Null
I've opened the database as below: -
Dim dbMyDB As Database
Dim rsMyRS As Recordset

Set dbMyDB = OpenDatabase("D:VB CodeDatabaseHardware maintenance.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("Hardware", dbOpenDynaset)


This is the bit of code I 'm having problems with: -

If rsMyRS.Fields("HardwareBOMNo") <> Null Then
MsgBox "Not Null"
End If

Instead of MsgBox "Not Null" will be code do do a search to check for duplicate records.

If the current field contains a Null value I don't want to search for duplicate but the code doesn't work. How do I check for a Null in a database field.

How To Check For Null In Txtbox And Do Somthing?
Hello.

I am using visual basic 6.

I have 20 textboxes and i have to load records into the textboxes. After loading, those who have null values inside the textbox, they shall be set to visible = false. Wat can i do abt it?

Thanks.

Variant Datatype Check For Null
Variant datatype check for null ...?

How To Check Null In Query If I Use Access
hello my self avi and i m developing bank application in vb 6 and ms access and ado2.1
i want to find out sum of amount from Receiptvoucher table.
but when there r no any record it return NULL and ineed to check that explicitly after executing query. i dont want to check out that explicitly. i want to do something that if there are no any records then query it self shoukd return 0.
i used IIf(isnull(sum(amount),0,sum(amount))  but it gives me error.
in sql i can use COALESCE() function in query or i can use Case Select statement in query but access doesnt support that what can i do plz help me
my query
select sum(Amount) from Receiptvoucher
it irretates me lots......................


and plz tell me instead of case select what can i use in access. plzzzzzzzzzzzz

How To Check Null In Query If I Use Access
hello my self avi and i m developing bank application in vb 6 and ms access and ado2.1
i want to find out sum of amount from Receiptvoucher table.
but when there r no any record it return NULL and ineed to check that explicitly after executing query. i dont want to check out that explicitly. i want to do something that if there are no any records then query it self shoukd return 0.
i used IIf(isnull(sum(amount),0,sum(amount)) but it gives me error.
in sql i can use COALESCE() function in query or i can use Case Select statement in query but access doesnt support that what can i do plz help me
my query
select sum(Amount) from Receiptvoucher
it irretates me lots......................


and plz tell me instead of case select what can i use in access. plzzzzzzzzzzzz

How Check Null In Select Statement
hello i m developing application in vb 6 and sql server 7
i want to retrive sum of amount from my salesvoucher table so my query is

select sum(amount) from Salesvoucher

whene there r no data in my table then it returns NULL and need to check that . i m checking that in following ways
curAmount=iif(ISNULL(rsSales(0))=true,0,rsSales(0))

but i dont want to check out this explicitly for that i used case in select statement but still it returns NULL so Plz give me some
suggetion on query or tell me any other way to do it

my case query
select case sum(Amount) when NULL then 0 else sum(Amount) end as Amount from salesvoucher

plz help me because i need it in all my procedure and function

How Do I Check Or Deal With NULL In Acces And ADO?
Hi all
   I have a database question. How do I deal with NULL using Access and ADO? Below is my code that should open my database and read all records and put them into ListView, however, when it finds a field with a NULL I get an error that says 'Invalid use of NULL'
There must be a pleasent way to deal with this.

Code:Private Sub Form_Load()
     Call updateList("SELECT * from Notes")
End Sub

Sub updateList(strSQL As String)
    Dim rs As ADODB.Recordset
    ListView1.ListItems.Clear
    'connect to the database and fill in next data
    Set cn = CreateObject("ADODB.Connection")
    cn.Open ("provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "Notes.mdb")
    Set rs = cn.Execute(strSQL)
    CheckDay = 1: Dim Temp(352): Dim Temp2(352): X = 1
    Dim itemTemp As ListItem
    Do While Not rs.EOF
        Set itemTemp = ListView1.ListItems.Add(, , rs(0).Value)
            itemTemp.SubItems(1) = (rs(1).Value) '<<< May contain NULL or no Data
            itemTemp.SubItems(2) = (rs(2).Value) '<<< May contain NULL or no Data
            Temp(X) = itemTemp.SubItems(1)     '<<< May contain NULL or no Data
            Temp2(X) = itemTemp.SubItems(2)     '<<< May contain NULL or no Data
            X = X + 1
        rs.MoveNext
    Loop
    cn.Close
    Set cn = Nothing
End Sub

Any Ideas, Any suggestions, Any way to fix this (I hope)?

Thanks in advance
Charles

How To Check NULL Value Of Field In Joined Table?
THe following print out 6 'this rec is null'.
I need only those record with Keywords.Name is NULL.
to delete those record from Codes_Keywords Table..

stmt = "SELECT Codes_Keywords.*, Keywords.* " & _
" FROM Codes_Keywords LEFT JOIN Keywords ON Codes_Keywords.KeywordID = Keywords.ID " & _
" ORDER BY Keywords.Name "

rec.Open stmt, conn, adOpenKeyset, adLockOptimistic
Debug.Print stmt
While Not rec.EOF
If IsNull(rec![Name]) Then
'Debug.Print rec![Name] & ": " & Asc(rec![Name])
Debug.Print "this rec is null"
End If
rec.MoveNext
Wend

To get Those records with Keyword.Name = NULL.
I tried write equivalent code for more efficiency.
I used following codes with New query adding
" WHERE Keywords.Name = NULL " & _ .
I expect it returns 6 records. But It returns ZERO record!!!
WHat is wrong???

stmt = "SELECT Codes_Keywords.*, Keywords.* " & _
" FROM Codes_Keywords LEFT JOIN Keywords ON Codes_Keywords.KeywordID = Keywords.ID " & _
" WHERE Keywords.Name = NULL " & _
" ORDER BY Keywords.Name "

rec.Open stmt, conn, adOpenKeyset, adLockOptimistic
Debug.Print stmt
While Not rec.EOF
If IsNull(rec![Name]) Then
'Debug.Print rec![Name] & ": " & Asc(rec![Name])
Debug.Print "this rec is null"
End If
rec.MoveNext
Wend

Thank you.

How To Check If Null??? – VB6 Datepicker Control With Checkbox
The issue I’m having is I need to be able to remove the data from a listview previously choosen from a datepicker control by unchecking the checkbox in the datapicker. When the checkbox is unchecked the datapicker’s value is Null. So I wrote the following:
Private Sub dtpScheduledDate_Click()

Dim sScheduledDate

As String

Dim sSQL

As String

Dim x

x = dtpScheduledDate.Value

If x Is Null Then

sScheduledDate = "Null"

End If
End Sub
This is giving me the following error: Run-time error ‘424’ Object required
I have tried: “If x Is Nothing then….” , “If x = Null Then….”, and “If Not x is Null Then…” (to see if the reverse even worked) and they give either the same error or it completely skips the step when it should not.
I am probably missing something small here but can’t seem to put my finger on it.
Any help would be greatly appreciated.
Thanks,
Becky

Pass Null For An Object
I have a function that gets passed a progressbar. However, I have a case where I want to use the function in another form that doesn't require a progress bar.

Is there something I can pass as NULL or do I have to have a fake textbox?

Null Object Pointer?
Hi,

I am having some difficulties with the way VB handles objects:

I need a dynamic array, so I use

Code:
Dim strBla() As String


I use "ReDim Preserve" to change its size. My problem is: how can I check if the array has no elements (before doing any ReDim)? In Java I would do it with


Code:
if (strBla == null)


In VB I found "Nothing" and "Null", but I can't use them in this case.

Can anyone help?

MS SQL 2000, DTSPackage Transformation, Check For NULL Values In Column
I am looking for instructions on properly checking for NULL values and then performing an action when a column in a file being imported is NULL.

CODE SNIPPET:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
elseif DTSDestination("Zip") =="" and
DTSDestination("State") = 'PR' or
DTSDestination("State") = 'RS' or
DTSDestination("State") = 'SC'
then DTSDestination("Rep1") = 0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I need to check if the DTSDestination("Zip") is a NULL Value.

Remember this is using the VB SCRIPTING in the MS SQL SERVER 2000 Import/Export Wizard Column Transformation.. which will ultimately be saved as a DTS Package once this part is figured out.

Can someone please point me in the right direction?

Thanks so much in advance.

- sp43t4r -

Null Value In OLE Object Type Field
I have an SQL server 2000 database with an OLE Object type field in it. The front end of the database was created (not by me) on foxpro. The table where that field is, already had a bunch of records (about 1200) with nothing in this specific field (null values) I did a mass append to the table with a DTS and left that field blank. In fact I did not even include it in my DTS.
When the users open the form for this table with one of my records they get an error message that says "there is nothing in that field". When they open one of the other records that were in the database before (where the field is also empty or null) they do not see the error.
I cannot check the application because is lock. What I want to know is how I can tell the database that this field is null. Any ideas?
Thanks

Dates Equal But Not Equal
I have this annoying problem and I am wondering if any of you have dealt with it before.

I have two variables that have the date stored in them. When I look at the text output of these two variable they are the same but if I do a comparison of these two variables VB says they are not the same.

In the Immediate Window I get the following:
Code:
? TempDate >= NextRunTime
False
? TempDate
11/2/2001 2:20:00 PM
? NextRunTime
11/2/2001 2:20:00 PM
? TempDate - NextRunTime
-2.18278728425503E-11
I am probably rounding off somewhere I shouldn't be. Has anyone seen this before and is there a work around?

Thanks

Object References And Null Data Problems
hi all, been working with some vbscript code, having some problems.
basically i use code similar to this:

Code:
On Error Resume Next
Set x = moo(0)
If x.Index = Index Then MsgBox "boo"
my code uses some functions to create controls and then i set a reference to them using vbscript. the problem is, sometimes i do not initialize variables when the program is run, sometimes i wait for certain events to make the variables create and reference something.
the problem is, in order to make the vbscript able to respond to user events, i use indices and i call a vbscript function when an object array raises an event. hopefully that makes sense. but, the vbscript functions then have to interpret which control had the event, so it has code like above, if Index=object1.index do this, if object2.index, do that, etc. however, i suppose because i am using references, the code doesnt work well. when x.index refers to nothing, it seems to evaluate true for every expression. x=null, x != null, x=2, x=3, etc. thus there is no way to prevent the code from executing, as you cannot tell whether the control actually exists. IsNull, IsEmpty, IsControl, and all those statements dont work either. Any ideas?

How To Cast Null Object To Empty String.
How do I cast an object into a string? The issue arises when the object returned is a null object, and if I try to store it into a string, it will cause a type error.


Code:
...
Dim lsVersion as String
Dim objXML As MSXML2.DOMDocument40
...
lsVersion = objXML.documentElement.getAttribute("ID")
...

When Does Excel's Range Object's Text Property Return Null
Was writing a function to determine whether a particular row in an Excel spreadsheet was empty or not. My spreadsheet has 21 columns labled. For me, if the 22nd column contains any text I wouldn't care as long as the other columns contain text. I wanted to detect if all of those 21 columns were empty. Here's my function.



Code:

Public Enum SpreadsheetColumns
EquipmentID = 0
Supplier = 1
Manufacturer = 2
ModelNumber = 3
LocationDept = 4
SerialNumber = 5
AcquisitionTerms = 6
LeaseEndDate = 7
PurchaseDate = 8
PurchasePrice = 9
Depreciation = 10
IsColorDevice = 11
PagesPrintedPerMonth = 12
AmountSupplies = 13
AmountServices = 14
CPPTotal = 15
CPPSupplies = 16
CPPService = 17
NumInvoices = 18
ApplicationData = 21
End Enum



Public Function GetColumnAlphabetFromIndex(ByVal ZeroBasedColumnIndex As SpreadsheetColumns) As String

If ZeroBasedColumnIndex < 0 Or ZeroBasedColumnIndex > 21 Then Exit Function

GetColumnAlphabetFromIndex = Choose _
(ZeroBasedColumnIndex + 1, _
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V")

End Function


Public Function IsRowEmpty(ByVal RowNumber As Long) As Boolean

Dim StrFromCell As String
Dim StrToCell As String

StrFromCell = GetColumnAlphabetFromIndex(SpreadsheetColumns.EquipmentID) & CStr(RowNumber)
StrToCell = GetColumnAlphabetFromIndex(SpreadsheetColumns.ApplicationData) & CStr(RowNumber)
If IsNull(Sheet1.Range(StrFromCell & ":" & StrToCell).Text) Then
IsRowEmpty = True
Else
IsRowEmpty = Trim(Sheet1.Range(StrFromCell & ":" & StrToCell).Text) = vbNullString
End If

End Function


Why does the line:


Code:
Sheet1.Range(StrFromCell & ":" & StrToCell).Text
return a value Null in my code when I actually have data in the row?

When Does Excel's Range Object's Text Property Return Null
Was writing a function to determine whether a particular row in an Excel spreadsheet was empty or not. My spreadsheet has 21 columns labled. For me, if the 22nd column contains any text I wouldn't care as long as the other columns contain text. I wanted to detect if all of those 21 columns were empty. Here's my function.



Code:


Public Enum SpreadsheetColumns
EquipmentID = 0
Supplier = 1
Manufacturer = 2
ModelNumber = 3
LocationDept = 4
SerialNumber = 5
AcquisitionTerms = 6
LeaseEndDate = 7
PurchaseDate = 8
PurchasePrice = 9
Depreciation = 10
IsColorDevice = 11
PagesPrintedPerMonth = 12
AmountSupplies = 13
AmountServices = 14
CPPTotal = 15
CPPSupplies = 16
CPPService = 17
NumInvoices = 18
ApplicationData = 21
End Enum



Public Function GetColumnAlphabetFromIndex(ByVal ZeroBasedColumnIndex As SpreadsheetColumns) As String

If ZeroBasedColumnIndex < 0 Or ZeroBasedColumnIndex > 21 Then Exit Function

GetColumnAlphabetFromIndex = Choose _
(ZeroBasedColumnIndex + 1, _
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V")

End Function


Public Function IsRowEmpty(ByVal RowNumber As Long) As Boolean

Dim StrFromCell As String
Dim StrToCell As String

StrFromCell = GetColumnAlphabetFromIndex(SpreadsheetColumns.EquipmentID) & CStr(RowNumber)
StrToCell = GetColumnAlphabetFromIndex(SpreadsheetColumns.ApplicationData) & CStr(RowNumber)
If IsNull(Sheet1.Range(StrFromCell & ":" & StrToCell).Text) Then
IsRowEmpty = True
Else
IsRowEmpty = Trim(Sheet1.Range(StrFromCell & ":" & StrToCell).Text) = vbNullString
End If

End Function





Why does the line:


Code:

Sheet1.Range(StrFromCell & ":" & StrToCell).Text


return a value Null in my code when I actually have data in the row?

Check If Object Is Set
Sorry if this is a dumb question.
Is there a way of checking if an object has been set.
At present I have a function which tries to retrieve a value from, in this case a class, and returns True/False. Obviously this only works in this specific case. Is there something more generic. I'm sure I'm missing something obvious here.

Check To See If An Object Is Set
All,
I have a range object that a .Find operation is being performed on it. If the value is not found withing the range. I need to increment the value being found. I wanted to do this with the following psuedocode:

Do Until RangeObject is set
with worksheet(1).range(myrange)
set RangeObject = .find(thisvalue, lookin:=xlvalues)
end with
if the rangeobject is not set then
incrment thisvalue
end if
end with
loop

My question is how to I test to see if RangeObject is not equal to Nothing. The code RangeObject <> Nothing is invalid. You help is appreciated.

How Can I Check Fro An Object?
i have a variable called prog
how can i check that its an object or not?
thnaks in advance
peleg

How Can I Check Fro An Object?
i have a variable called prog
how can i check that its an object or not?
thnaks in advance
peleg

Check An Object
Hi,

Thanks for reading. Iam declaring an Object

VB Code:
Dim Con as Object


Now Iam assigning an ADO Connection object to this. This is a DLL which will be accessed many times. So I don't want to create the connection again and again.
Now how do I check for an object to be empty. This is not working.

VB Code:
Dim objCon as new ADODB.CONNECTIONIf IsNull(Con) then    Set Con = objConEnd if

what method can I use to check whether the Object has something in it or not.

Thanks,
Pres.

Check If Object = Nothing
How can you check if an object is set to Nothing ??

the instruction

If obj = Nothing

does not work ..

How Can I Check Fro An Object?
i have a variable called prog
how can i check that its an object or not?
thnaks in advance
peleg

Check Whether An Object Is Nothing Or Not
Hi all,

In my program now, I have an object that somtimes it is Nothing. At that time, if I try to access it, there will be a Runtime Error. In order to fix that problem, before I access that object, I check whether it is Nothing. I use

If myObject <> Nothing then
' I do something here
End If

but when I try to compile that code, I get compile error "Invalid use of object" and VB highlights the keyword "Nothing". I don't know why??? How can I check if a object is Nothing????

Thanks for your help

VB: How To Check If Object Is Nothing?
Dear All,

How do you check an object in Visual Basic if it (the value) is Nothing?
I've tried the code below but I received a compiler error.

Code:

If rangeTableOffset = Nothing Then <-- compiler error here.
...

End If

Any help you may have is very much appreciated.
Thanks in advance.


Owen

Checkbox..... Check Check Check Check Check...oops Stack Error
I have three check boxes one on each of my SSTab tabs. If one is checked the other two needs to be unchecked.... and so on. I use this to determine which is the default website. Ok....here is the code I used....

Select Case Index
Case 0
chkDefaultWebsite(1).Value = vbUnchecked
chkDefaultWebsite(2).Value = vbUnchecked
' Case 1
chkDefaultWebsite(0).Value = vbUnchecked
chkDefaultWebsite(2).Value = vbUnchecked
Case 2
chkDefaultWebsite(0).Value = vbUnchecked
chkDefaultWebsite(1).Value = vbUnchecked
End Select

Simple enough right? Well the first time I click on the check box, my box isn't checked but my others are unchecked....so when I click again it checks it..... so I did this....

Select Case Index
Case 0
chkDefaultWebsite(0).Value = vbChecked
chkDefaultWebsite(1).Value = vbUnchecked
chkDefaultWebsite(2).Value = vbUnchecked
Case 1
chkDefaultWebsite(0).Value = vbUnchecked
chkDefaultWebsite(1).Value = vbChecked
chkDefaultWebsite(2).Value = vbUnchecked
Case 2
chkDefaultWebsite(0).Value = vbUnchecked
chkDefaultWebsite(1).Value = vbUnchecked
chkDefaultWebsite(2).Value = vbChecked
End Select

And of course I get a stack error of endless days err...I mean looping on the check box.....

How can I get that to check the first time I click on it and also uncheck the others ???

Thanks again !

Check Object Existence
hi everybody...

is there a way to test whether or not an object (any object) does exist?

Copyright © 2005-08 www.BigResource.com, All rights reserved