Solved

else if statment & print

Posted on 2002-05-11
5
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

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 120 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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