473,408 Members | 2,477 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,408 software developers and data experts.

Help in converting vb.net function to C#.net

1
I need help converting vb.net code to c#. here it is.

Expand|Select|Wrap|Line Numbers
  1.  
  2.     'Get the ID File Type from file path name
  3.     Public Function GetFileType(ByVal fileName As String) As EFile
  4.         Dim i As Integer
  5.         For i = 0 To SFile
  6.             If InStr(1, fileName, VTFile(i).fileExt) = Len(fileName) - Len(VTFile(i).fileExt) + 1 Then
  7.                 GetFileType = VTFile(i).fileID
  8.                 Exit Function
  9.             End If
  10.         Next
  11.         GetFileType = EFile.NOTDEF
  12.     End Function
  13.  
**Edited:**

This is what i got so far in C#
Expand|Select|Wrap|Line Numbers
  1.  
  2.         //Get the ID File Type from file path name
  3.         public EFile GetFileType(string fileName)
  4.         {
  5.             EFile functionReturnValue = default(EFile);
  6.             int i = 0;
  7.             for (i = 0; i <= SFile; i++)
  8.             {
  9.                 if (Strings.InStr(1, fileName, VTFile[i].fileExt) == Strings.Len(fileName) - Strings.Len(VTFile[i].fileExt) + 1)
  10.                 {
  11.                     functionReturnValue = VTFile[i].fileID;
  12.                     return functionReturnValue;
  13.                 }
  14.             }
  15.             functionReturnValue = EFile.NOTDEF;
  16.             return functionReturnValue;
  17.         }
  18.  
i get errors at this line:
Expand|Select|Wrap|Line Numbers
  1.     if (Strings.InStr(1, fileName, VTFile[i].fileExt) == Strings.Len(fileName) - Strings.Len(VTFile[i].fileExt) + 1)
  2.  
its complaining of "Strings.IpStr()" and "Strings.Len()".
Error code:The name 'Strings' does not exist in the current context.

thanks in advance
Jul 20 '12 #1
0 20076

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

Similar topics

1
by: Thomas Connolly | last post by:
Hello list, No one seems to be replying to my request on the interop group so I thought I would try here. Can someone please help me with this? I have a C struct containing function pointers like...
4
by: jipster | last post by:
hi, i need help converting this java program to C++...are there any programs or nething that could be used to do this faster?? class hw2 { static public void main (String args) { hw2.test();}...
0
by: MDB | last post by:
Hello All, I have a function in a 3rd party dll that I am trying to use however, I am unsure how to convert to C# Can anyone help or give me some pointers? Here is what the documentation states:...
7
by: jj | last post by:
It seems simple but I had a hard time converting this small function from vb.net to C#. I even tried the software that automatically converts from vb to c# , but to no avail. Please can someone...
5
by: David | last post by:
I note that you can null teminate a string by adding controlchar.null. Is there a way of adding a null to a Buffer of Bytes and converting it to a string. I have packets coming in from a...
13
by: ppateel | last post by:
Hi, I am new to c++ and I am converting a c program to c++. I changed malloc call to new and I am getting an exception violation. Here is the relevant piece of code. Compiler vc++ 7.0 (.Net...
16
by: manmit.walia | last post by:
Hello All, I have tried multiple online tools to convert an VB6 (bas) file to VB.NET file and no luck. I was hoping that someone could help me covert this. I am new to the .NET world and still...
1
by: pollardw | last post by:
i have written a small program to convert Fahrenheit to Celsius and I have a minor problem. Here is the code what do i need to change to get it to work? /* Convert Fahrenheit to Celsius */ ...
9
by: whitgurley | last post by:
I've searched the web as well as I can for a solution to this problem but have found nothing and just don't know enough about JavaScript to figure out what's going. What I'm trying to do is convert...
9
by: victory2006 | last post by:
I need help converting a list into a string ex/ i want to compare this, "110"(string) to this (list) to see if they are identical. So, how would you do this? convert the string into a list?...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.