Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

else if statment & print

Posted on 2002-05-11
5
Medium Priority
?
144 Views
Last Modified: 2010-05-02
Hi
How can I use the if ststment in VB I tried to use it but it gives me error

Aslo how I can print which command Im using ADODC connection and I want to print All the fields with thier labels

Please tell me ASAP



 If invoice.Text1.Text = "" Then
    invoice.Text1.Text = Text1.Text
    invoice.Text2.Text = Text7.Text
    invoice.Text5.Text = Text2.Text
    invoice.Text6.Text = Text12.Text
    Adodc1.Recordset.Update
    invoice.Text4.Text = Date
   
     num = Val(Text9.Text)
     num = num - Text12.Text
     Text9.Text = num
     Text9.SetFocus
     Adodc1.Recordset.Save
     Frame2.Visible = False
     Parts.Hide
Else if//////////////I does not work
    invoice.Text7.Text = Text1.Text
    invoice.Text12.Text = Text7.Text
    invoice.Text10.Text = Text2.Text
    invoice.Text11.Text = Text12.Text
   
   
   
Else if  invoice.Text7.Text = (0) Then///////doesnot work
    invoice.Text15.Text = Text1.Text
    invoice.Text18.Text = Text7.Text
    invoice.Text16.Text = Text2.Text
    invoice.Text17.Text = Text12.Text
    invoice.Show
     End If
0
Comment
Question by:furious581
5 Comments
 
LVL 3

Expert Comment

by:Randy Bristow
ID: 7003693
you have no condition listed for this else if

Else if//////////////I does not work
   invoice.Text7.Text = Text1.Text
   invoice.Text12.Text = Text7.Text
   invoice.Text10.Text = Text2.Text
   invoice.Text11.Text = Text12.Text


try:


Else if PLACE CONDITION HERE Then
   invoice.Text7.Text = Text1.Text
   invoice.Text12.Text = Text7.Text
   invoice.Text10.Text = Text2.Text
   invoice.Text11.Text = Text12.Text


Randy
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 360 total points
ID: 7003787
Else if  invoice.Text7.Text = (0) Then///////doesnot work
   invoice.Text15.Text = Text1.Text
   invoice.Text18.Text = Text7.Text
   invoice.Text16.Text = Text2.Text
   invoice.Text17.Text = Text12.Text
   invoice.Show
    End If

change to
Else if  invoice.Text7.Text = "0" Then///////doesnot work
   invoice.Text15.Text = Text1.Text
   invoice.Text18.Text = Text7.Text
   invoice.Text16.Text = Text2.Text
   invoice.Text17.Text = Text12.Text
   invoice.Show
    End If

a comparison of .text field requires a string.


An option could be
If invoice.Text1.Text = "" Then
  YOUR CODE FOR THIS PART
Elseif  invoice.Text7.Text = "0"
  YOUR CODE FROM THIS PART
Else
  YOUR CODE FROM THE ELSEIF WITHOUT THE COMDITION
end if


mlmcc
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7003802
and use elseif instead of else if
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7003921
And use Select case if possible instead of a bunch of elseif.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7004721
your code should look like this:

Elseif  invoice.Text7.Text = "0" Then
  invoice.Text15.Text = Text1.Text
  invoice.Text18.Text = Text7.Text
  invoice.Text16.Text = Text2.Text
  invoice.Text17.Text = Text12.Text
  invoice.Show
End If

It is also a VERY goopd idea to NAME your text boxes with MEANINGFUL names, rather that keep the DEAFULT names (Text1 does not mean anything where txtInterestRate or txtValue does).  Just a suggestion.

Arthur Wood

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question