473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

In operator

Hi
If i want to use IN operator in VB , then how can i use it?

i mean i want to something like this

If Mid(WholeLine, 22, 3) In ("JAN" ,"FEB") then

but it gives me error.

i would appreciate any help.
thanks
Oct 3 '07 #1
15 1394
hariharanmca
1,977 1GB
Hi
If i want to use IN operator in VB , then how can i use it?

i mean i want to something like this

If Mid(WholeLine, 22, 3) In ("JAN" ,"FEB") then

but it gives me error.

i would appreciate any help.
thanks
You can use inStr() function Like

Expand|Select|Wrap|Line Numbers
  1. If inStr(1,Mid(WholeLine, 22, 3), ("JAN" ,"FEB") ) > 0 then
Oct 3 '07 #2
thanks
i tried but still gives me error
thanks alot for quick answer
Oct 3 '07 #3
hariharanmca
1,977 1GB
thanks
i tried but still gives me error
thanks alot for quick answer
can you post what you had tried and what is the error you are getting?
Oct 3 '07 #4
elseif inStr(1,Mid(WholeLine,22,3),("JAN,"FEB","MAR","APR "))>0 then

and it said
expected :)

thanks
Oct 3 '07 #5
hariharanmca
1,977 1GB
elseif inStr(1,Mid(WholeLine,22,3),("JAN,"FEB","MAR","APR "))>0 then

and it said
expected :)

thanks
I am not getting what you mean!

What expected?
Oct 3 '07 #6
the error message is

Expected:)

this is my error message
do u want me to take printscreen?
Oct 3 '07 #7
Hi,

Try this code. It may suitable to you.

Switch(Mid("SampleTestingXXXXXXXXJAN", 22, 3) = "JAN", "JANUARY", _
Mid("SampleTestingXXXXXXXXJAN", 22, 3) = "FEB", "FEBRUARY")


Regards
------------
Mahesh
Oct 3 '07 #8
hariharanmca
1,977 1GB
Expand|Select|Wrap|Line Numbers
  1. elseif inStr(1,Mid(WholeLine,22,3),("JAN,"FEB","MAR","APR"))>0 then
Use like this


Expand|Select|Wrap|Line Numbers
  1. elseif inStr(1,("JAN FEB MAR APR"),Mid(WholeLine,22,3))>0 then
Oct 3 '07 #9
i will try now
but may i ask what is usage of that 1

what i want to do that if Mid(WholeLine, 22, 3) is equal to jan, feb,... dec,
then i be able to read that fiels and then do something
but i have no idead waht is the role of that 1 and why i have to say >0

thanks alot
Oct 3 '07 #10
hariharanmca
1,977 1GB
i will try now
but may i ask what is usage of that 1

what i want to do that if Mid(WholeLine, 22, 3) is equal to jan, feb,... dec,
then i be able to read that fiels and then do something
but i have no idead waht is the role of that 1 and why i have to say >0

thanks alot
Just consider your
Expand|Select|Wrap|Line Numbers
  1. Mid(WholeLine, 22, 3) = "JAN"
  2. 'Then the inStr will look like
  3. If InStr(1, ("JAN FEB MAR APR"), "JAN") > 0 Then
  4.  
which means
inStr(<Start from Char 1>,<String content As String 1>, <Search String as string 2>) > 0

this > 0 meant string is available else not available
Note : this inStr will return the possition of string 2 in string 1
Oct 3 '07 #11
thanks alot for your explanation. so i shouldnt put any comma between jan and feb?
if i put coma then it wont work

thankssssssssssssssss
Oct 3 '07 #12
Killer42
8,435 Expert 8TB
... so i shouldnt put any comma between jan and feb?
if i put coma then it wont work
Actually, in this case it probably would. The Instr() function just tells you where inside a string it finds another string. If "JAN" is in there, it probably won't care whether there are commas, spaces or anything else around it.
Oct 3 '07 #13
hariharanmca
1,977 1GB
No, Actully he/she mean "JAN", "FEB",.....etc
Oct 3 '07 #14
Killer42
8,435 Expert 8TB
No, Actully he/she mean "JAN", "FEB",.....etc
Good point. Instr() is only designed to search one string, not a bunch of them. Of course, you could easily create a function to accept an array and do a search of it like Instr() if you wanted to. It could be a useful thing to have in one's toolkit.
Oct 3 '07 #15
Thanks for all helps
now secong problem is come up

as i said before the month can be different
the last 3 month is in differnt rows. but is going and just reading one line and i have same entry for my whole table.

my text file has two different king of data entry.
i have to read the date and the report type and member name.
then i dont need some lines and then i have to read the month. the last 3 month is usually there and then after i read the month name i read teh whole line.
but the main problem is that i am getting same information for everything.
the name of member or data will change but all the information that relate to the month is repeated same.

the first pasrt of my textfile is 19 line and then it is seperated with the second section with ----------------- (dash line)
then second format will started and then it will finish by some thing that is wrriteen END OF REPORT. again the first report will start.and then second type.

but i dont know how can i say that just read till line 19 and then stop when you see dash line.
because the way i did is that it is going and read line by line.
i did some thing like this that when MID(wholeline,9,3)= date then do this but it is not working properly.
Oct 5 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
1
by: joesoap | last post by:
Hi can anybody please tell me what is wrong with my ostream operator??? this is the output i get using the 3 attached files. this is the output after i run assignment2 -joesoap #include...
5
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more...
0
by: Martin Magnusson | last post by:
I have defined a number of custom stream buffers with corresponding in and out streams for IO operations in my program, such as IO::output, IO::warning and IO::debug. Now, the debug stream should...
3
by: Sensei | last post by:
Hi. I have a problem with a C++ code I can't resolve, or better, I can't see what the problem should be! Here's an excerpt of the incriminated code: === bspalgo.cpp // THAT'S THE BAD...
6
by: YUY0x7 | last post by:
Hi, I am having a bit of trouble with a specialization of operator<<. Here goes: class MyStream { }; template <typename T> MyStream& operator<<(MyStream& lhs, T const &)
3
by: gugdias | last post by:
I'm coding a simple matrix class, which is resulting in the following error when compiling with g++ 3.4.2 (mingw-special): * declaration of `operator/' as non-function * expected `;' before '<'...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
8
by: valerij | last post by:
Yes, hi How to write "operator +" and "operator =" functions in a class with a defined constructor? The following code demonstrates that I don't really understand how to do it... I think it has...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.