Solved

else if statment & print

Posted on 2002-05-11
5
137 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 1

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 100

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

730 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