TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Suganda Suganda
NA
24
10.9k
Help to convert Microsoft.VisualBasic.Right to C# code
Mar 12 2018 7:10 PM
I have vb.net code, i try the code to C#. But microsoft.visualbasic.right not found in C# code. I don't know how to convert that. Can you help me to convert this code?
This is vb.net code
Sub Autonumber()
'Koneksi()
Dim _Urutan As String
Dim _Hitung, _Cari As Long
CMD = New OdbcCommand(
"Select * from data where kode in "
&
"(select max(kode) from data)"
, CONN)
RD = CMD.ExecuteReader
RD.Read()
If Not RD.HasRows Then
_Urutan =
"K"
&
"001"
Else
_Cari = Microsoft.VisualBasic.Right(RD.GetString(0), 3)
If Microsoft.VisualBasic.Left(RD.GetString(0), 1) <>
"K"
Then
_Urutan =
"K"
&
"001"
Else
_Hitung = Microsoft.VisualBasic.Right(RD.GetString(0), 3) + 1
_Urutan =
"K"
& Microsoft.VisualBasic.Right(
"000"
& _Hitung, 3)
End If
End If
RD.Close()
txtCode.Text = _Urutan
End Sub
This in c# code
public
void
Autonumber()
{
string
_Urutan;
long
_Hitung, _Cari;
CMD =
new
OdbcCommand(
"Select * from data where kode in "
+
"(select max(kode) from data)"
, CONN);
RD = CMD.ExecuteReader();
RD.Read();
if
(!RD.HasRows)
{
_Urutan =
"K"
+
"001"
;
}
else
{
_Cari = Microsoft.VisualBasic.Right(RD.GetString(0), 3);
if
(Microsoft.VisualBasic.Left(RD.GetString(0), 1) !=
"K"
)
{
_Urutan =
"K"
+
"001"
;
}
else
{
_Hitung = Microsoft.VisualBasic.Right(RD.GetString(0), 3) + 1;
_Urutan =
"K"
+ Microsoft.VisualBasic.Right(
"000"
+ _Hitung, 3);
}
}
RD.Close();
txtCode.Text = _Urutan;
}
Reply
Answers (
3
)
Input string not in correct formate when query return null t
Creating jpeg image file