problem with mid function

Posted by Amar888 under C# on 7/28/2010 | Views : 4501 | Status : [Member] | Replies : 4
hi,
i convert vb to c# , after convertion below code but it not accepted "Strings.Mid(MonthName)" . If any body know pls tell me .
main problem with mid function, in c# its not there , how can i use ?


strSTartMonth = Strings.Mid(MonthName(dsRows[i]["FeeCollectMonth"]), 1, 3);




Responses

Posted by: Bangarubabu on: 7/28/2010 [Member] Starter

Up
0
Down
strSTartMonth = Strings.Mid(MonthName(ds.Rows["FeeCollectMonth"] ), 1, 3);

ds.Rows["FreeCollection"] does not Returns String --Just Convert that Row value into String

string s=ds.Rows["FreeCollection"].ToString();


strSTartMonth = Strings.Mid(s, 1, 3);


I hope it will helps






BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/

Amar888, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ambily.raj on: 7/29/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down

strSTartMonth = Strings.Mid(MonthName(dsRows["FeeCollectMonth"]), 1, 3);

dsRows["FeeCollectMonth"]) seems to be return a number indicating the FeeCollectMonth and using MonthName method it converts the number into corresponding MonthName. Using the Strings.Mid() method, it converts the full month name to abbreviated month name.

Then, you can convert the same in C# as

string feeCollectMonth = dsRows["FeeCollectMonth"].ToString();

strSTartMonth = new DateTimeFormatInfo().AbbreviatedMonthNames[Int32.Parse(feeCollectMonth )-1];



Thanks
Ambily K K
http://ambilykk.com/

Amar888, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Duraikannan on: 12/17/2010 [Member] Starter | Points: 25

Up
0
Down
using Microsoft.VisualBasic;

using Microsoft.VisualBasic namespace in C#.net application. for example

Microsoft.VisualBasic.Strings.Mid("SampleText Here",2,3);


Amar888, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Duraikannan on: 12/24/2010 [Member] Starter | Points: 25

Up
0
Down
string lstr="Welcome";
MessageBox.Show(Microsoft.VisualBasic.Strings.Mid(str, 4, 4));

"Come" will be apper..





Amar888, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response