473,771 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 20082

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

Similar topics

1
1474
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 so: typedef struct _tagLiffeResponseHandlerList { void (*OnAccessTransfer) (LiffeStatus eStatus, const char* pszTrader, LiffeBoolean bContinuationFlag, int nNumOrders, const LiffeOrderEntryList* pcLiffeOrderEntryList, time_t nTimeStamp);
4
1767
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();} Board board = new Board(8); if ( board.fillInRemainingLevels() ) board.print(); else System.out.println("Couldn't find solution");
0
1027
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: DWORD IBT_DeviceDiscovery (PIBTDEVICE pbtDev, BYTE *pnDevs); This function will perform a Device Discovery and store the results for each device in a IBTDEVICE structure. pbtDev is a pointer to an allocated array of IBTDEVICE structures.
7
2056
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 take some precious minutes to help me out. Thanks John Public Function SimpleCrypt( ByVal Text As String) As String Dim strTempChar As String, i As Integer
5
4188
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 serial ports as bytes and some of these represent strings. (Like the Packed BCD date/time stamp etc). At present I read through each Byte and convert to char and append to a string.
13
4655
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 2003) SQLINTEGER nCols; SQLINTEGER cbColDataLength; PBYTE* pColumnData = NULL;
16
5448
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 learning all help would be greatly apperciated. Attribute VB_Name = "Module1" Option Explicit
1
3200
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 */ #include <iostream> #include <iomanip> #include <string>
9
8559
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 this script: <a href="#" onclick="MM_goToURL('parent.frames','color2.html');return document.MM_returnValue">TEST</a> ....to something that I can use within a Flash movie, which as far as I can tell means that it needs to reside in the...
9
3136
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? the list into a string? then compare the two? thanks in advance
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.