c語言agebox,c語言age是什麼

本文目錄一覽:

C語言。。messagebox用法

窗體上放置三個TextBox,分別輸入a,b,c的值,控件命名:tbA,tbB,tbC

再放一個Button,設置Text為:求解,其單擊後台代碼如下:

private void button1_Click(object sender, EventArgs e)

{

double a = 0;

double b = 0;

double c = 0;

try

{

if (tbA.Text.Length == 0)

{

MessageBox.Show(“請輸入a的值”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

return;

}

a = Convert.ToDouble(tbA.Text);

}

catch

{

MessageBox.Show(“您輸入的a的值不是一個數字,請重新輸入”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

tbA.Focus();

return;

}

try

{

if (tbB.Text.Length == 0)

{

MessageBox.Show(“請輸入b的值”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

return;

}

b = Convert.ToDouble(tbB.Text);

}

catch

{

MessageBox.Show(“您輸入的b的值不是一個數字,請重新輸入”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

tbB.Focus();

return;

}

try

{

if (tbC.Text.Length == 0)

{

MessageBox.Show(“請輸入c的值”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

return;

}

c = Convert.ToDouble(tbC.Text);

}

catch

{

MessageBox.Show(“您輸入的c的值不是一個數字,請重新輸入”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

tbC.Focus();

return;

}

if (a == 0)

{

if (b == 0)

{

if (c == 0)

{

MessageBox.Show(string.Format(“方程{0}x^2+{1}x+{2}=0的解為 x={3}”, a, b, c, “任意實數”), “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

}

else

{

MessageBox.Show(string.Format(“方程{0}x^2+{1}x+{2}=0無實數解”, a, b, c), “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

else

{

MessageBox.Show(string.Format(“方程{0}x^2+{1}x+{2}=0的解為 x={3}”, a, b, c, -c / b), “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

else

{

double delta = b * b – 4 * a * c;

if (delta 0)

{

MessageBox.Show(string.Format(“方程{0}x^2+{1}x+{2}=0無實數解”, a, b, c), “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

}

else

{

MessageBox.Show(string.Format(“方程{0}x^2+{1}x+{2}=0的解為 x1={3} , x2={4}”, a, b, c, (-b + System.Math.Sqrt(delta)) / 2 / a, (-b – System.Math.Sqrt(delta)) / 2 / a), “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

}

用c語言如何實現彈除對話框

#include

#include

char format[]=”%s%s\n”;

char hello[]=”Hello”;

char world[]=”world”;

HWND hwnd;void main(void)

asm

//push NULL

//call dword ptr GetModuleHandle

//mov hwnd,eax push MB_OK mov eax,offset world push eax mov eax,offset hello push eax push 0//說明此處不能將前面注釋掉代碼處得到的hwnd壓棧,否則對話框彈不出來。

call dword ptr MessageBox

}

}

WINDOWS程序MessagBox

WINDOWS或控制台 assert

C/C++ code

// crt_assert.c

// compile with: /c

#include stdio.h

#include assert.h

#include string.h

void analyze_string( char *string );   // Prototype

int main( void )

{

char  test1[] = “abc”, *test2 = NULL, test3[] = “”;

printf ( “Analyzing string ‘%s’\n”, test1 ); fflush( stdout );

analyze_string( test1 );

printf ( “Analyzing string ‘%s’\n”, test2 ); fflush( stdout );

analyze_string( test2 );

printf ( “Analyzing string ‘%s’\n”, test3 ); fflush( stdout );

analyze_string( test3 );

}

// Tests a string to see if it is NULL,

// empty, or longer than 0 characters.

void analyze_string( char * string )

{

assert( string != NULL );        // Cannot be NULL

assert( *string != ‘\0’ );       // Cannot be empty

assert( strlen( string ) 2 );  // Length must exceed 2

}

擴展資料:

#include windows.h

#include Commdlg.h

#include stdio.h

// 返回值: 成功 1, 失敗 0

// 通過 path 返回獲取的路徑

int FileDialog(char *path)

{

OPENFILENAME ofn;

ZeroMemory(ofn, sizeof(ofn));

ofn.lStructSize = sizeof(ofn); // 結構大小

ofn.lpstrFile = path; // 路徑

ofn.nMaxFile = MAX_PATH; // 路徑大小

ofn.lpstrFilter = “All\0*.*\0Text\0*.TXT\0”; // 文件類型

ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

return GetOpenFileName(ofn);

}

int main(char argc, char *argv[])

{

char szFile[MAX_PATH] = {0};

if(FileDialog(szFile))

{

puts(szFile);

}

getchar();

return 0;

}

C語言中messagebox的用法

消息框的函數原型:

int MessageBox(HWND hwnd,LPCTSTR lpsztext,LPCSTR lpsztitle,UINT ustyle);

消息框函數有4個參數:

第1個參數是父窗口的句柄。為NULL,說明消息框沒有父窗口。

第2個參數就是一個指向要顯示字符串的指針

第3個參數是消息框本身的標題。

第4個參數是指定消息框的內容和形為(即該消息框有幾個按鈕、文本對齊等狀態,可以在20多個屬性值中進行組合)

MessageBox的第4個參數可以是在WINUSER.H中定義的一組前綴以MB_開始的常數組合.

可以使用C語言的”或”(|)運算符將下面顯示的三組中各選一個常數組合起來指定消息框的內容和形為:

顯示哪些按鈕:

#define MB_OK 0X00000000L

#define MB_OKCANCEL 0X00000001L

#define MB_ABORTRERYGNORE 0X00000002L

#define MB_YESNOCANCEL 0X00000003L

#define MB_YESNO 0X00000004L

#define RERYCANCEL 0X00000005L

焦點在哪個按鈕上:

#define MB_DEFBUTTON1 0X00000000L

#define MB_DEFBUTTON2 0X00000100L

#define MB_DEFBUTTON3 0X00000200L

#define MB_DEFBUTTON4 0X00000300L

圖示的外觀:

#define MB_ICONHAND 0x00000010L

#define MB_ICONQUESTION 0x00000020L

#define MB_ICONEXCLAMATION 0x00000030L

#define MB_ICONASTERISK 0x00000040L

圖示的某些有替代名稱:

#define MB_ICONWARNING MB_ICONEXCLAMATION

#define MB_ICONERROR MB_ICONHAND

#define MB_ICONINFORMATION MB_ICONASTERISK

#define MB_ICONSTOP MB_ICONHAND

示例:

MessageBox(NULL, “Hello, Windows!”,”hello”, MB_OK );

MessageBox(NULL, “Hello, Windows!”,”HelloMsg”, MB_YESNO|MB_ICONEXCLAMATION) ;

MessageBox(NULL, “Hello, Windows!”,”HelloMsg”, MB_YESNO|MB_DEFBUTTON1) ;//表示窗口出來後焦點 focus落在Yes(第一個)按鈕上

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/195994.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-12-03 09:52
下一篇 2024-12-03 09:52

相關推薦

  • AES加密解密算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES算法,並對實現過程進…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演着非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python被稱為膠水語言

    Python作為一種跨平台的解釋性高級語言,最大的特點是被稱為”膠水語言”。 一、簡單易學 Python的語法簡單易學,更加人性化,這使得它成為了初學者的入…

    編程 2025-04-29
  • OpenJudge答案1.6的C語言實現

    本文將從多個方面詳細闡述OpenJudge答案1.6在C語言中的實現方法,幫助初學者更好地學習和理解。 一、需求概述 OpenJudge答案1.6的要求是,輸入兩個整數a和b,輸出…

    編程 2025-04-29
  • Python按位運算符和C語言

    本文將從多個方面詳細闡述Python按位運算符和C語言的相關內容,並給出相應的代碼示例。 一、概述 Python是一種動態的、面向對象的編程語言,其按位運算符是用於按位操作的運算符…

    編程 2025-04-29
  • Python語言由荷蘭人為中心的全能編程開發工程師

    Python語言是一種高級語言,很多編程開發工程師都喜歡使用Python語言進行開發。Python語言的創始人是荷蘭人Guido van Rossum,他在1989年聖誕節期間開始…

    編程 2025-04-28
  • Python語言設計基礎第2版PDF

    Python語言設計基礎第2版PDF是一本介紹Python編程語言的經典教材。本篇文章將從多個方面對該教材進行詳細的闡述和介紹。 一、基礎知識 本教材中介紹了Python編程語言的…

    編程 2025-04-28
  • Python語言實現人名最多數統計

    本文將從幾個方面詳細介紹Python語言實現人名最多數統計的方法和應用。 一、Python實現人名最多數統計的基礎 1、首先,我們需要了解Python語言的一些基礎知識,如列表、字…

    編程 2025-04-28
  • Python作為中心語言,在編程中取代C語言的優勢和挑戰

    Python一直以其簡單易懂的語法和高效的編碼環境而著名。然而,它最近的發展趨勢表明Python的使用範圍已經從腳本語言擴展到了從Web應用到機器學習等廣泛的開發領域。與此同時,C…

    編程 2025-04-28
  • Python基礎語言

    Python作為一種高級編程語言擁有簡潔優雅的語法。在本文中,我們將從多個方面探究Python基礎語言的特點以及使用技巧。 一、數據類型 Python基礎數據類型包括整數、浮點數、…

    編程 2025-04-28

發表回復

登錄後才能評論