Hi all, I have a code of C++ and VB.NET after converting. But the stringname.GetBuffer is got error on blue string. What are the code equivalent to VB.Net? Below are the code from C++ and VB.NEt:
C++ code:
void ImageSetup::SetBitmap()
{
CString tmpFile,DumpFile,ImageFileName;
int strLen;
char *srcFile;
char rsp[200];
CString szFileBmp1,szFileBmp2,szFileBmp3;
int FileNameCount;
ImageFileName = "Check_.bmp";
HBITMAP bmp;
bmp = NULL;
char *file_name= LPSTR(LPCTSTR(ImageFileName));
SetBmp(file_name);
tmpFile = ImageFileName;
strLen = tmpFile.GetLength();
strLen -= 4;
tmpFile.Insert(strLen,"F"); srcFile = tmpFile.GetBuffer(tmpFile.GetLength());
szFileBmp1 = srcFile;
tmpFile = ImageFileName;
strLen = tmpFile.GetLength();
strLen -= 4;
tmpFile.Insert(strLen,"R"); srcFile = tmpFile.GetBuffer(tmpFile.GetLength());
szFileBmp2 = srcFile;
tmpFile = ImageFileName;
strLen = tmpFile.GetLength();
tmpFile.Replace(".bmp",".TIF");
strLen -= 4;
tmpFile.Insert(strLen,"RB"); srcFile = tmpFile.GetBuffer(tmpFile.GetLength());
szFileBmp3 = srcFile;
if( m_bCheck12 == TRUE)
{
tmpFile = DumpFile;
FileNameCount++;
strLen = tmpFile.GetLength();
tmpFile.Replace(".bmp","");
wsprintf(rsp,"%04d.bmp",FileNameCount);
tmpFile += rsp; app_tbl.ImageFileName = tmpFile;
}
}
VB.NET code:
Public Sub SetBitmap()
Dim tmpFile As String
Dim DumpFile As String
Dim ImageFileName As String
Dim strLen As Integer
Dim srcFile As String
Dim rsp As New String(New Char(199){})
Dim szFileBmp1 As String
Dim szFileBmp2 As String
Dim szFileBmp3 As String
Dim FileNameCount As Integer
ImageFileName = "Check_.bmp"
Dim bmp As System.IntPtr
bmp = Nothing
Dim file_name As SByte = CStr(CStr(ImageFileName))
SetBmp(file_name)
tmpFile = ImageFileName
strLen = tmpFile.Length
strLen -= 4
tmpFile = tmpFile.Insert(strLen,"F")
srcFile = tmpFile.GetBuffer(tmpFile.Length)
szFileBmp1 = ChrW(srcFile)
tmpFile = ImageFileName
strLen = tmpFile.Length
strLen -= 4
tmpFile = tmpFile.Insert(strLen,"R")
srcFile = tmpFile.GetBuffer(tmpFile.Length)
szFileBmp2 = ChrW(srcFile)
tmpFile = ImageFileName
strLen = tmpFile.Length
tmpFile = tmpFile.Replace(".bmp",".TIF")
strLen -= 4
tmpFile = tmpFile.Insert(strLen,"RB")
srcFile = tmpFile.GetBuffer(tmpFile.Length)
szFileBmp3 = ChrW(srcFile)
If m_bCheck12 = [TRUE] Then
tmpFile = DumpFile
FileNameCount += 1
strLen = tmpFile.Length
tmpFile = tmpFile.Replace(".bmp","")
rsp = String.Format("{0:D4}.bmp", FileNameCount)
tmpFile &= ChrW(rsp)
ImageFileName = tmpFile
End If
End Sub
The only thing that make me wonder is the GetBuffer function from a string. Is it exist? Or can some see this things and help me out. A little help is highly appreciate. Thank you