Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C++
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");			// front
	srcFile = tmpFile.GetBuffer(tmpFile.GetLength());
	szFileBmp1 = srcFile;

	tmpFile = ImageFileName;
	strLen = tmpFile.GetLength();
	strLen -= 4;
	tmpFile.Insert(strLen,"R");			// Rear
	srcFile = tmpFile.GetBuffer(tmpFile.GetLength());
	szFileBmp2 = srcFile;

	tmpFile = ImageFileName;
	strLen = tmpFile.GetLength();
	tmpFile.Replace(".bmp",".TIF");
	strLen -= 4;
	tmpFile.Insert(strLen,"RB");			// Rear
	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;//".bmp";
		app_tbl.ImageFileName = tmpFile;
	}
}


VB.NET code:
VB
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") ' front
    srcFile = tmpFile.GetBuffer(tmpFile.Length)
    szFileBmp1 = ChrW(srcFile)

    tmpFile = ImageFileName
    strLen = tmpFile.Length
    strLen -= 4
    tmpFile = tmpFile.Insert(strLen,"R") ' Rear
    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") ' Rear
    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) '".bmp";
        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
Posted

1 solution

GetBuffer is useless in both C++ and VB.NET programs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900